CSS Cascade Layers

Back

Demo of CSS Cascade layers. Grouping CSS into layers with specificy order.

Syntax example

View this demo page's CSS file to get to know the syntax.

Demo's: this heading should be deeppink not green

This cards heading should be blue not deeppink

This heading should be purple

Lorem ipsum dolor sit amet consectetur, adipisicing elit. Dolore, necessitatibus!

This heading should be purple

Lorem ipsum dolor sit amet consectetur, adipisicing elit. Dolore, necessitatibus!

This heading should be purple

Lorem ipsum dolor sit amet consectetur, adipisicing elit. Dolore, necessitatibus!

Lorem ipsum dolor sit amet consectetur, adipisicing elit. Dolore, necessitatibus!

Things to keep in mind

  • The first CSS file in the HTML-head should tell the browser what layers and what their order should be
  • You can import 2nd or 3rd party CSS (hardcoded, root- or relative URL paths) straight into your own CSS (using @import url(/path/to/css/file.css);) and assign those to a layer
  • If you happen to use, CSS !important; after your CSS value, that will only work the first time it's been registered.
  • You can nest CSS Cascade Layers inside CSS Cascade Layers
  • CSS styles NOT specified inside a @layer have a higher speceficity.