Frontend Engineering
CSS Architecture and Performance
Quiz: Cascade Resolution
advanced9 min read
Trace the Full Cascade Algorithm
Each question presents conflicting CSS rules. Your job: determine which declaration wins by tracing the cascade algorithm — origin, layers, specificity, source order. These are the edge cases that separate CSS experts from CSS users.
If you can get 6+ out of 8, you understand the cascade at an architectural level.
Question 1: Layer vs Specificity
@layer base, utilities;
@layer base {
#main .hero h1.title {
color: navy;
}
}
@layer utilities {
.text-red {
color: red;
}
}
The element has id="main", classes hero, title, and text-red.
Quiz
Question 2: !important in Layers (Inversion)
@layer reset, components;
@layer reset {
a { color: blue !important; }
}
@layer components {
.link { color: red !important; }
}
The element is <a class="link">.
Quiz
Question 3: Unlayered vs Layered
@layer components;
@layer components {
.btn {
background: blue;
color: white;
}
}
.btn {
background: green;
}
Quiz
Question 4: Inheritance vs Cascade
.parent {
color: red;
}
.child {
color: inherit;
}
.parent .child {
color: blue;
}
Quiz
Question 5: :where() and Source Order
:where(#sidebar) .widget {
padding: 1rem;
background: white;
}
.widget {
padding: 2rem;
background: gray;
}
Quiz
Question 6: Inline Style vs !important
<div class="box" style="color: red;">
.box { color: blue !important; }
Quiz
Question 7: Animation vs Cascade
.box {
color: red;
animation: colorize 2s forwards;
}
@keyframes colorize {
to { color: blue; }
}
.box { color: green; }
During the animation, what color is the text?
Quiz
Question 8: Nested Layers
@layer framework {
@layer base, components;
}
@layer app;
@layer framework.components {
.card { border: 2px solid blue; }
}
@layer app {
.card { border: 1px solid gray; }
}
@layer framework.base {
.card { border: 3px solid red; }
}
Quiz
Scoring Guide
| Score | Assessment |
|---|---|
| 8/8 | You can trace the full cascade algorithm including layers, !important inversion, and animation priority. Staff-level CSS knowledge. |
| 6-7 | Strong understanding with minor gaps. Review !important layer inversion and animation cascade priority. |
| 4-5 | Decent foundation but layer interactions trip you up. Study the cascade algorithm order carefully. |
| 0-3 | Revisit the cascade deep dive and cascade layers lessons. Focus on the algorithm steps in order. |