HTML/CSSIntermediate#css#cascade#specificity

What does !important do and why should it generally be avoided?

!important overrides normal specificity rules, forcing a declaration to win regardless of selector weight. It should be avoided because it breaks the natural cascade, makes debugging harder, and forces overuse elsewhere to override it, creating a specificity arms race.

Example
.text { color: black !important; }
/* Even a more specific selector below cannot override this without its own !important */
#header .text { color: red; } /* loses */

Related Questions

1
HTML/CSSIntermediate#css#pseudo-elements

What is the CSS 'content' property used for with pseudo-elements?

Open
2
HTML/CSSBeginner#css#display

What is the difference between inline, inline-block, and block for form control styling?

Open
3
HTML/CSSAdvanced#css#internationalization

How do CSS logical properties (like margin-inline, padding-block) differ from physical properties?

Open