Cascade Layers
Last updated:
Layer order should control CSS precedence intentionally — not selector escalation wars.
01 — Purpose
Predictable CSS ordering
Cascade layers reduce specificity wars — layer order should control precedence, not selector escalation.
Without layers, teams fight with ever-longer selectors and !important.@layer lets you declare precedence once so overrides stay intentional and readable.
This site uses LSCSS — seeCSS standard and CSS architecture for how layers fit the wider system.
02 — Principles
Order beats escalation
Declare layer order intentionally — then place files in the right layer.
- avoid unlayered CSS — it overrides every layer; fix precedence with layer order instead
- lower layers provide defaults; higher layers refine — not the reverse
- avoid fighting layers with specificity — if you need to, the layer order is wrong
03 — Structure
Layer order on this site
Match the order declared in your entry file — on Frontend Foundations:
legacy— vendor CSS, old frameworks, third-party sheets (sometimes calledthirdpartyin other LSCSS setups)settings— tokens, fonts, breakpointsbase— reset, typography defaultsutilities— single-purpose helperslayout— page shell, containerscomponents— UI blockstheme— colour and theme overrideshacks— documented exceptions only
@layer legacy, settings, base, utilities, layout, components, theme, hacks;
@import './legacy/vendor.css' layer(legacy);
@import './settings/tokens.css' layer(settings);
@import './components/card.css' layer(components);04 — Benefits
What layers buy you
Less !important, clearer overrides, safer scaling.
- predictable overrides — utilities can beat components without specificity hacks
- reduced
!importantusage across the codebase - clearer ownership — new files land in the right folder and layer
- safer third-party CSS — isolate vendor styles in the
legacylayer until migrated
05 — Close
Reduce conflict, not add ceremony
Layers should simplify decisions — if the layer list grows past comprehension, simplify the system.
Start with a small, documented layer stack. Add layers when you have a recurring conflict pattern — not preemptively for every folder.
Related: design tokens, container queries.