concept

cascade-sorting — CSS reference

Compare declarations only after discarding inapplicable rules. Origin/importance comes before context and element-attached style; layer ordering precedes specificity. Equal selector weight is resolved by applicable scope proximity, then source order. A later high-specificity declaration does not recover from losing an earlier comparison.

Formal Syntax & Structure

css syntaxcss
@layer base, app; /* layer order before selector weight */

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>CSS reference lab</title><style>@layer base,app; @layer app {.note{color:#006050}} @layer base {#a{color:#802020}} p {background-color:white} @media (min-width:10000px){#a{color:blue!important}}</style><body><p id="a" class="note">Field note</p><p id="b">Control</p></body></html>
CSS Reference