DEV Community

Discussion on: Using !important in CSS

Collapse
 
urielbitton profile image
Uriel Bitton • Edited

Sometimes you need to apply styles to elements abstractly so you can't get specific with your selectors.
Also online styles will override !important if you add !important to the online style itself.

Collapse
 
alvaromontoro profile image
Alvaro Montoro • Edited

When I find elements that are too generic to style, I normally solve it by adding a class/id to the elements or one of their ancestors, which allows for easier and more specific selectors. Do you have an example of applying styles to elements abstractly and how did you fix it with !important?

Also, inline styles do not override !important as it can be seen in this example:

Collapse
 
urielbitton profile image
Uriel Bitton

Right i actually meant inline with !importa overrides styleseet !important