Question about the !important keyword

In “Learn More About CSS Pseudo Selectors By Building A Balance Sheet”:

Step 47:

" Rather than having to constantly double-check you are not overwriting your earlier properties, you can use the !important keyword to ensure these properties are always applied, regardless of order or specificity.

Give each property in your span[class~="sr-only"] selector an !important keyword. Do not change any of the values."

Is this a good way, as I was told the !important keyword should be used only in exceptional situations? “Otherwise it is a sign of less qualitive codeing”.

What is the point-of-view on this nowadays in the world of development?

it’s a thing to know about, I see it mostly used in external stylesheets that override the css of the page, like for example in a dark mode browser extension. As css rules are so that the most specific rule has precedence on more generic ones, sometimes the only way to make that element in particular have that style you want is to use the !important keyword

1 Like

Thanks for clarifying that, ilenia!

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