The reset is protected, and Teo’s components layer keeps growing. It contains the captions, the masthead, and the call for poems, and the issue page will add poem cards and issue navigation. One flat layer will soon hold dozens of rules.
In this lesson, you’ll split components into nested layers, predict which rule wins between them, and hand one property back to a lower layer without copying its value. Start by giving the cards a layer of their own.
Group Components in Nested Layers
A layer can hold other layers. An @layer block written inside another block creates a nested layer, and an order statement inside the block sets the order of its nested layers, the same way the statement at the top of the file orders the outer ones. Replace the @layer components block in styles.css with this one:
@layer components {
@layer cards, nav;
@layer cards {
.issue-note {
display: flex;
align-items: baseline;
gap: 1rem;
margin-bottom: 2rem;
padding: 1rem 1.5rem;
border: 2px solid #9b2226;
}
.cover-caption {
font-family: Georgia, serif;
font-style: italic;
text-transform: none;
color: #2b2118;
}
}
.masthead {
margin-bottom: 4rem;
padding: 1.5rem;
color: #fbf7f0;
background: #2b2118;
}
}
Save, and the page doesn’t change, because the rules only moved. The nav layer stays empty until the issue navigation arrives. From outside the block, the nested layers are called components.cards and components.nav.