Skip to content

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
What color is the h1?

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
What color is the link?

Question 3: Unlayered vs Layered

@layer components;

@layer components {
  .btn {
    background: blue;
    color: white;
  }
}

.btn {
  background: green;
}
Quiz
What background does .btn have?

Question 4: Inheritance vs Cascade

.parent {
  color: red;
}

.child {
  color: inherit;
}

.parent .child {
  color: blue;
}
Quiz
What color is the child?

Question 5: :where() and Source Order

:where(#sidebar) .widget {
  padding: 1rem;
  background: white;
}

.widget {
  padding: 2rem;
  background: gray;
}
Quiz
What is the widget's padding and background?

Question 6: Inline Style vs !important

<div class="box" style="color: red;">
.box { color: blue !important; }
Quiz
What color is the text?

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
During the animation, what color is the box?

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
What border does .card have?

Scoring Guide

ScoreAssessment
8/8You can trace the full cascade algorithm including layers, !important inversion, and animation priority. Staff-level CSS knowledge.
6-7Strong understanding with minor gaps. Review !important layer inversion and animation cascade priority.
4-5Decent foundation but layer interactions trip you up. Study the cascade algorithm order carefully.
0-3Revisit the cascade deep dive and cascade layers lessons. Focus on the algorithm steps in order.