DEV Community

Discussion on: CSS Specificity

Collapse
 
rhymes profile image
rhymes

Cool article, thanks Emma!

Didn't know there was a formula to calculate specificity nor tools to aid. They might be handy when you're trying to debug :)

You may run into situations when leveraging CSS frameworks, such as Bootstrap, where you can't use CSS specificity to override the native styles. In these instances, using !important is not considered bad practice.

Bootstrap is the main reason we use !important :D Fortunately I see less and less Bootstrap around.

Collapse
 
ellissei_studio profile image
Elisei Miron

Personally I'm a big fan of Bootstrap 4 grid, since they use flexbox.

But regarding the Bootstrap overrides, don't override it with !important.
Customise it by overriding the sass variables instead of styles for every component. A good example is bootswatch.com.