CSS cascade layers let you set predictable priority groups for stylesheets. For normal declarations, later layers outrank earlier ones, and unlayered author styles outrank all explicitly layered author styles. For !important declarations, that layer order reverses. The cascade checks layer priority before selector specificity, so a lower-specificity rule can win when it is in a higher-priority layer.
Where layers fit in the CSS cascade
Layers are one stage of the cascade, not a replacement for it. A rule must first apply to the element and property in question. The cascade then considers factors including origin and importance, encapsulation context, layer priority, specificity, scoping proximity, and source order. A layer cannot overcome a declaration that already wins at an earlier stage, such as a declaration from a higher-priority origin/importance category. See the W3C CSS Cascading and Inheritance Level 5 specification and MDN’s cascade overview.
For ordinary competing author styles, the useful working sequence is: confirm both rules apply, compare origin and importance, compare context, compare layer, and only then compare specificity and later tie-breakers. A selector that looks stronger may still lose because specificity is not considered until layer precedence is settled. MDN explains the limits of specificity in its specificity guide.
Which CSS layer has priority?
Within the same origin and comparable context, normal declarations in later layers have higher priority than normal declarations in earlier layers. Normal author declarations outside named layers are treated as belonging to an implicit final layer, so they outrank normal declarations in explicit author layers.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minute#1 Best Overall
For example, the normal-style order below runs from lower to higher priority:
reset < vendor < components < utilities < unlayered author styles
This is why a utility rule can beat a more specific component rule, and why an unlayered rule can unexpectedly beat carefully layered styles. MDN’s cascade layers guide covers the normal and important ordering rules.
Declare layer order before adding styles
A layer’s position is established when its name first appears. Repeating a layer name adds styles to that layer; it does not move the layer to a new position. Declare the intended order near the start of your stylesheet so imports and conditional rules do not establish an unintended order first.
Rank #2
@layer reset, vendor, base, components, utilities;
You can then put declarations in named blocks:
@layer components {
.card {
border-radius: 0.5rem;
}
}
Stylesheets imported with @import can also be assigned to a layer:
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →@import url("vendor.css") layer(vendor);
Conditional group rules can affect the global layer order when their conditions create layers. If you need a stable order, declare the names deliberately before conditional blocks. For syntax and additional details, see MDN’s @layer reference.
Use layers to resolve a specificity conflict
In this example, both rules target the same element and property, are normal author declarations, and apply in the same relevant context:
@layer framework, app;
@layer framework {
#main .button {
color: navy;
}
}
@layer app {
.button {
color: tomato;
}
}
The .button declaration in the later app layer wins, even though #main .button is more specific. The cascade settles layer precedence before selector specificity. An unlayered normal author declaration for the same property would outrank both explicit layers.
Layers are useful for separating broad concerns such as resets, vendor styles, application defaults, components, and utilities. The W3C specification describes layers as a way to represent defaults, libraries, themes, components, and overrides, and to reorder their cascade without changing selectors or relying on source order across layers.
Important declarations reverse layer priority
For declarations marked !important, layer priority reverses: important declarations in earlier layers outrank important declarations in later layers. Important declarations inside explicit layers also outrank unlayered important author declarations. This exception means you should not assume the normal-style order applies to every declaration. MDN documents this behavior in its !important reference.
Rank #4
Because !important changes the priority model and can make maintenance harder, it is not a dependable everyday override strategy. Prefer an explicit layer order and keep declarations in the intended layers.
Nested layers and conditional rules
Layers can be nested. A name such as framework.theme refers to a theme sublayer nested under framework; its order is considered within that parent. Nested layers are not simply independent top-level layers, and declarations placed directly in a parent have ordering details relative to its nested sublayers. When the exact comparison matters, consult the W3C specification and the @layer reference.
Likewise, layers first encountered inside conditional group rules can make ordering harder to predict. An up-front layer-order statement is a practical safeguard when a stylesheet has media queries, supports conditions, or imports that contribute layers.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Best Value
Diagnose why a rule did not win
- Check applicability. Confirm both selectors match the same element and set the same property, and that any media, supports, or other conditions are active.
- Compare origin and importance. Determine which origin supplied each declaration and whether either uses
!important. These comparisons happen before ordinary layer precedence. - Check context. Confirm the declarations are in comparable encapsulation contexts, such as light DOM versus shadow DOM.
- Identify each layer. Find where each layer name first appeared. For normal declarations, the later layer wins; for important declarations, the earlier layer wins. A normal unlayered author declaration beats normal declarations in explicit author layers.
- Compare specificity only after those checks. Specificity matters when the earlier cascade comparisons are tied. If specificity is also tied, account for scoping proximity and order of appearance where relevant.
This order of checks avoids the common mistake of increasing selector specificity before finding out that the declaration is losing at the layer stage—or at an earlier stage.
Or skip the browser setup
If you need a rendered screenshot while checking a page, ScreenshotNeo can capture it with one GET request. For example, this cURL command saves a WebP screenshot of the target URL:
Quick Recap
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo documentation for request options. It removes cookie or consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are not billed. Its MCP server lets AI agents use screenshot tools, and 1,000 screenshots a month are free with no card; paid plans start at $5 for 3,000. Learn about ScreenshotNeo or sign up for 1,000 free screenshots a month with no card.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.




