⌘K
Flycodx

CSS Specificity & the Cascade

CSS Specificity & the Cascade

EasyFrontend0% accepted

A button's colour won't change no matter what class you add. Explain CSS specificity, the cascade, and how the browser decides which rule wins. Cover: specificity scoring (inline > id > class > element), the role of source order, why !important is a last resort, and how to debug an overridden style.

Approach

Specificity ranks selectors: inline(1000) > id(100) > class/attr/pseudo-class(10) > element(1). Ties break by source order. !important overrides all but creates maintenance pain.

Scenarios & Expected Answers

No example scenarios for this problem.

Sign in to continue

Create a free account to view answers and mark progress.

  • Free forever — no credit card
  • Theory Q&A with detailed answers
  • Points, streaks & leaderboards
Auto Save On