0Pricing
CSS Academy · Lesson

Adding Styles to Layers

Assign CSS rules to specific layers using @layer blocks and imported stylesheets.

Two Ways to Add Styles to Layers

You can add styles to a layer inline (inside an @layer block) or via @import (to assign an imported stylesheet to a layer).

Inline @layer Block

Wrap rules inside an @layer block with the layer name:

@layer components {
  .button {
    padding: 10px 20px;
    background: royalblue;
    color: white;
    border-radius: 4px;
  }
}

All lessons in this course

  1. @layer Declaration and Ordering
  2. Adding Styles to Layers
  3. Layer Priority and !important Interaction
  4. Layers in Third-Party Code
← Back to CSS Academy