Koskamo

Cascade and specificity: which declaration wins

Document v1 · published by Koskamo editorial · updated 2026-10-04

Original source

Specificity is the weight browsers use in the cascade algorithm to determine which declaration applies, and it is compared only between selectors from the cascade origin and layer that has precedence — browsers evaluate specificity after establishing origin and importance. The specificity value is a three-column ID-CLASS-TYPE count: each ID selector adds 1-0-0; each class, attribute selector, or pseudo-class adds 0-1-0; each type selector or pseudo-element adds 0-0-1. The universal selector, the :where() pseudo-class, and combinators add zero weight; :is(), :has(), :not(), and nesting add none themselves, but their parameters or nested components contribute the weight of their most specific matching selector. Columns are compared left to right, so a higher ID-column value wins regardless of the other columns' totals. When competing selectors share equal specificity, scoping proximity and then order of appearance decide the winner. Scope: CSS cascade and specificity. Reviewed October 4, 2026.

Source and provenance

Original source
developer.mozilla.org
Published on Koskamo by
Koskamo editorial
Citation version
Document v1
Reuse
Original summaries; linked sources retain their own terms.

The original source supplies the underlying information. Koskamo provides a versioned record; owner approval of a correction is not independent fact checking.