The cascade and the box · core
Specificity, the cascade and @layer
When rules conflict, the cascade decides by origin and importance, then cascade layer, then specificity (id, class, element counts), then source order; @layer lets you order whole groups so a later layer wins regardless of specificity.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Specificity is (ids, classes/attributes/pseudo-classes, elements/pseudo-elements). Inline styles beat selectors; !important beats normal declarations.
- :is() and :not() take the specificity of their most specific argument; :where() is always 0.
- @layer reset, base, components, utilities; — later layers win; unlayered styles beat layered ones.
- Inheritance: some properties inherit (color, font), most don't (margin, border).
The red pen
Common traps: mistake → fix
Mistake: "a class always beats an element selector"
Fix: only at the same layer; layer order is checked before specificity.
Mistake: "!important is fine to fix bugs"
Fix: it starts an arms race; fix with layers or lower specificity.
Easy to hard
Questions interviewers ask, easy to hard
- How does the browser decide which rule wins?
- What does @layer solve?
- Specificity of :where() vs :is()?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.