×

css · level 3 · unit 2 · lesson 4

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

One line at the top decides the .

Layers rank by when the browser first meets their name, which gets fragile when files are combined. So professionals write the layer order once, at the very top: @layer reset, base, components, utilities;. Later blocks fill those layers in, wherever they appear.

Rules outside every layer are , and unlayered rules beat all layers. That is handy for a quick fix, but it also means old code with no layers can quietly beat your whole new system.

<a class="btn" href="https://example.com/join">Join</a>
@layer base, components;
@layer components {
  .btn {
    color: white;
    background-color: #0f766e;
  }
}
@layer base {
  a {
    color: #264653;
  }
}

Press show my page to see it here.

The base block sits last in the file, but the first line already ranked it below components.