@layer order
The first declared layer order defines priority between layers.
Cascade layers let you define priority between groups of CSS before specificity gets involved. They are a modern way to make large stylesheets calmer.
@layer reset, base, components, utilities;
@layer components { .button { color: white; } }
@layer utilities { .text-accent { color: #8cffc1; } }
Cascade & Control
Cascade layers are created with @layer. They let you say which group of CSS should have priority over another group.
This is different from specificity. A low-specificity rule in a later-priority layer can beat a higher-specificity rule in an earlier layer.
Layers are useful when a project has resets, base styles, components, utilities or third-party CSS. They make the architecture visible instead of relying only on selector weight and file order.
The first declared layer order defines priority between layers.
Useful for reset and base styles that should be easy to override.
Useful for components, utilities or controlled overrides.
Specificity decides inside the same layer, not across layer priority.
Visual model
The browser does not apply styles emotionally. It follows a priority system. These diagrams make that priority visible before you start changing declarations.
Normalize browser differences and low-level defaults.
Set typography, body, links and document defaults.
Style buttons, cards, nav and forms.
Small purposeful overrides with clear names.
Examples
@layer reset, base, components, utilities;
@layer base {
a { color: #62d5ff; }
}
@layer components {
.button { color: #061018; }
}
@layer utilities {
.text-accent { color: #8cffc1; }
}
@layer components { .button { color: white; } }
@layer base { a { color: blue; } }
@layer randomFixes { .button { color: red; } }
/* Nobody knows which layer should own the decision. */
Rules that matter
CSS becomes easier when every override has a reason. If a rule wins by accident, the next developer has to debug your intention instead of the code.
Put @layer reset, base, components, utilities near the top.
A layer should describe a purpose, not a random folder name.
Layers help when CSS has enough scale to need priority control.
A simple utility in a later layer can beat a complex selector in an earlier layer.
Vendor styles can live in a lower layer so your site CSS can override them cleanly.
Developers should know where a new rule belongs.
Production thinking
Layers move CSS architecture from hidden convention into actual browser behavior. That is huge for larger projects where resets, components and utilities need predictable priority.
Put accessibility utilities or focus-state protections in a predictable layer so component rules do not accidentally erase them.
Cascade layers are production-ready in modern workflows, but you should still check browser support requirements for your audience.
Layered CSS helps maintain stable interfaces. Stable, usable interfaces support the content experience that search engines indirectly reward.
Live code lab
The preview runs in an isolated iframe. Links and forms stay inside the practice area, so you can experiment without leaving the lesson.
Mini assignment
Practice assignment
Try it yourself
Self-check
Answer these questions before moving on. If the answer is vague, inspect the lab example and trace which declaration wins.
Senior audit upgrade
Cascade layers make architecture visible, but they introduce a key nuance: unlayered normal author styles outrank layered normal author styles.
The first @layer order declaration defines layer priority for the project.
Normal declarations outside layers can beat layered normal declarations, even if the layered selector looks stronger.
Important declarations reverse some layer ordering expectations, so test important plus layers carefully.
@layer reset, base, components, utilities;
@layer components {
.button { color: white; }
}
.button { color: red; } /* unlayered normal can win */