← All notes

The CSS cascade: how conflicting rules are resolved

Answer: The cascade is an algorithm for solving conflicts where multiple CSS rules apply to an HTML element. The cascade algorithm is split into 4 distinct stages. Cascade layers are the @layer CSS rule.

Four stages of the cascade

CSS stands for Cascading Stylesheets.

When more than one rule applies to an element, the cascade is what decides the winner.

The cascade algorithm is split into 4 distinct stages: position and order of appearance, specificity, origin, and importance (including !important).

When every other step of the cascade is equal, the last style will win.

Origin and importance

Authored CSS is not the only CSS applied to a page.

Origin matters: default browser styles and styles from a browser extension also enter the cascade.

Cascade layers

Cascade layers are expressed with the @layer CSS rule.

They give you more explicit control over CSS files so style-specificity conflicts are easier to prevent.

This is useful for large codebases, design systems, and when managing third party styles in applications.

Once styles are layered, the precedence of a layer always beats the specificity of a selector.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: web.dev, The cascade; Chrome Developers, Cascade layers are coming to your browser. CC-BY-4.0 (https://web.dev/learn/css/flexbox). Copyright Google LLC. web.dev text is CC BY 4.0. CC-BY-4.0 (https://developers.google.com/site-policies). Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License. Copyright Google LLC. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: web.dev, The cascade; Chrome Developers, Cascade layers are coming to your browser. CC-BY-4.0 (https://web.dev/learn/css/flexbox). Copyright Google LLC. web.dev text is CC BY 4.0. CC-BY-4.0 (https://developers.google.com/site-policies). Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License. Copyright Google LLC.

Cite this

Permanent ID: iil:note:nmvqxf46

iinventedlight. 2026. "The CSS cascade: how conflicting rules are resolved." iinventedlight Library, iil:note:nmvqxf46, version of 2026-11-23. https://iinventedlight.com/library/notes/css-cascade/. License: CC-BY-4.0.

@misc{iil_note_nmvqxf46,
  author = {{iinventedlight}},
  title = {{The CSS cascade: how conflicting rules are resolved}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-23},
  url = {https://iinventedlight.com/library/notes/css-cascade/},
  note = {Permanent ID iil:note:nmvqxf46. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/css-cascade.md.