What the cascade decides
When several CSS declarations set the same property on the same element, the
cascade picks the winner. Before specificity or source order ever come into
play, the cascade first sorts declarations by their origin (who wrote them)
and importance (normal vs !important). Getting this order right explains
why a heavily-specific author rule can still lose to a humble user-agent default
marked !important.
How it works
The cascade compares declarations top to bottom through these tiers (highest priority first):
- Transitions
- User-agent
!important - User
!important - Author
!important - CSS animations
- Author normal
- User normal
- User-agent normal
The key insight is the !important reversal: for normal declarations the
order is author over user over user-agent, but for !important declarations it
flips to user-agent over user over author. This protects user and accessibility
overrides. Cascade layers (@layer) subdivide the author tiers, and only when
two declarations tie on all of the above does the engine fall through to
specificity and then source order.
Tips and notes
A transition always wins so animation never jams behind a static !important
rule. Within author styles, unlayered declarations beat layered ones for normal
rules — but that too reverses under !important. If a rule “won’t apply” despite
high specificity, check whether something higher in this origin table (often a
user-agent or user !important) is quietly outranking it. The comparison tool
below resolves any two declarations for you.