Learn More About CSS Pseudo Selectors By Building A Balance Sheet - Step 30

I don’t see it explained anywhere why we use span[class~="sr-only"] instead of just .sr-only to select this class; can someone explain, please?

1 Like

This selector will target only span elements that have .sr-only class, which means the properties written in that selector block will only be applied to span elements with .sr-only

However, if you have another element that is not a span element but has a .sr-only class, the css properties applied in span[class~="sr-only"] will not apply to this element

Hope the explanation is clear and answers your question,
regards

1 Like

Thank you! That was helpful.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.