Caffeinated Coder
Book an appointment
Lesson 03 · Styling basics

The cascade and specificity

When several rules set the same property on the same element, the browser must pick one. Watch four rules fight over one paragraph's colour: every selector matches, each gets a specificity score (IDs, classes, tag names), equal scores are settled by which rule comes later, and a higher score wins wherever it is written. Then delete the id and see a different rule win.

10 min8 steps5 questionsBeginner
Fig 3 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.