CSS cascade layers, a CSS feature that allows us to define explicit contained layers of specificity,
so that we have full control over which styles take priority in a project without relying on specificity.
In CSS, there is such a thing as a layer. It must be said that it is familiar to everyone who has worked with any graphic editor, but, perhaps, it is still incomprehensible to others.
When creating a block in CSS, we always clearly set its parameters, as well as position it in a certain place on the screen. Thus, any block has two coordinates X and Y, which determine the position of the block on the screen plane. But in CSS there is also a third, spatial coordinate Z, which determines the number of the layer on which the block is located.
@layer reset, defaults, framework, components, utilities;
That will establish the layer order:
- un-layered styles (most powerful)
- utilities
- components
- framework
- defaults
- reset (least powerful)
but remember: what matters is the order each name first appears. So this will have the same result:
@layer reset, defaults, framework;
@layer components, defaults, framework, reset, utilities;
layers are stacked based on the order in which the layers first appear in your code
check this css-tricks.com/css-cascade-layers and https://www.successbeta.com/2022/10/learn-about-layers-in-css-step-by-step.html for further clarifications.