intermediatetermCSSCSS / CSS fundamentals / Specificity
IntermediateNot yet reviewed

Specificity

Specificity is a score for how targeted a selector is.

Definition

Specificity is a score for how targeted a selector is. IDs outrank classes, which outrank plain tag names, and the highest score wins.

Use case

Overly specific selectors are why later edits get ignored. Keep selectors flat and class based so they stay easy to override.

Related terms

Documentation

Specificity

MDN · Docs

Shows exactly how the score is calculated, with examples.

Suggest a change