CSS: !important
The !important keyword
the !important has highest cascade priority.
when two rules are both !important, the one with higher specificity or later in the cascade, wins.
p { color: red !important; } /* beats everything below */ #id8383 .xclass p { color: blue; }
The priority of !important
- (lowest),User-agent normal
- User normal
- Author normal
- Animations
- Author !important
- User !important
- User-agent !important
- (highest),Transitions
Normal declarations follow the usual order:
- user-agent.
- user
- author
- author important.
- user important
- user-agent important
An author !important declaration beats any normal declaration (including more specific ones or later ones), but loses to user or user-agent !important declarations.
Within the same origin + importance level, the rest of the cascade still applies:
- Cascade layers (order is also reversed for !important)
- Specificity
- Source order (later wins)
🛑 WARNING: do not use the !important, because it makes your CSS hard to maintain once you have more than one.