Set layer order
@layer reset, base, components, utilities;
@layer groups author styles into an explicit cascade order. A later normal layer can override an earlier one even when the earlier selector is more specific, making frameworks, components, and utilities easier to coordinate.
@layer reset, base, components, utilities; fixes the order before layer blocks appear.
@layer reset, base, components, utilities;
@layer components {
.button { /* styles */ }
}| Form | Purpose | Try it |
|---|---|---|
| order statement | Declare named layer priority | Try it |
| named block | Put rules in a named layer | Try it |
| anonymous block | Create a layer that cannot be reopened by name | Try it |
| nested layer | Create sublayers inside a parent | Try it |
| layered import | Place imported styles in a layer | Try it |
| unlayered rule | Compare layered and unlayered priority | Try it |
@layer reset, base, components, utilities;@layer components { .button { color: white; } }
@layer utilities { .text-black { color: black; } }@layer framework {
@layer base, components;
}@layer is a browser cascade feature.
Supported by current Chrome, Edge, Firefox, Safari, and Opera.
Bottom line: Safe for current browsers. Keep a sensible source order if older browser behavior matters.
Adapt components to their available space.
CODETOFUN NEWS
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
6 people found this page helpful