---
source: https://iinventedlight.com/library/notes/css-specificity.md
title: "CSS specificity: how competing selectors are scored"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC-BY-4.0 (web.dev); CC-BY-4.0 (Chrome Developers); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: web.dev, Specificity; Chrome Developers, Cascade layers are coming to your browser. CC-BY-4.0 (https://web.dev/learn/css/flexbox). Copyright Google LLC. web.dev text is CC BY 4.0. CC-BY-4.0 (https://developers.google.com/site-policies). Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License. Copyright Google LLC."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-23
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-23
as_of: 2026-11-23
confidence: medium
untested: "Not reproduced (2026-11-23). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-web: css-specificity"
tags: [css, specificity, selectors, cascade-layers, web]
client: Librarian
sources:
  - id: S1
    title: "Specificity"
    publisher: web.dev
    url: https://web.dev/learn/css/specificity
    accessed: 2026-11-23
    license: "CC-BY-4.0"
  - id: S2
    title: "Cascade layers are coming to your browser"
    publisher: Chrome Developers
    url: https://developer.chrome.com/blog/cascade-layers
    accessed: 2026-11-23
    license: "CC-BY-4.0"
---
# CSS specificity: how competing selectors are scored
**Answer:** Specificity is a cascade stage that scores competing CSS rules. The score is a triad of A, B, and C, not a decimal number. The highest-specificity rule wins. Keep scores only as high as you need.

## The specificity triad

Specificity is one distinct stage of the cascade.

A, B, and C form a triad, not a decimal number.

A is id-like, B is class-like, and C is element-like, often in (A,B,C) notation.

Declarations from rules with the highest specificity win.

## How selectors add points

The triad starts at (0,0,0). A universal selector adds no specificity.

An element or pseudo-element increments C by 1, so div is (0,0,1).

A class, pseudo-class, or attribute selector increments B by 1.

#myID increments A by 1 and scores (1,0,0), unlike the [id="myID"] form.

The :not() and :is() pseudo-classes do not themselves add to the specificity calculation. :where() always has a specificity of (0,0,0).

A style attribute does not affect specificity, and neither does !important, which only changes origin.

## When layers outrank a selector score

The @layer rule adds cascade layers that can prevent specificity conflicts.

With layered styles, layer precedence always beats selector specificity.

Layered styles create new cascade planes.

## See also

- [css-cascade](https://iinventedlight.com/library/notes/css-cascade/)
- [css-custom-properties](https://iinventedlight.com/library/notes/css-custom-properties/)
- [css-flexbox-basics](https://iinventedlight.com/library/notes/css-flexbox-basics/)

## Claims

- id: C1
  claim: Declarations from rules with the highest specificity win.
  source: S1
  evidence: "Declarations from rules with the highest specificity win"

- id: C2
  claim: The specificity score is a triad of components A, B, and C.
  source: S1
  evidence: "a triad that consists of three components"

- id: C3
  claim: A universal selector adds no specificity.
  source: S1
  evidence: "adds no specificity"

- id: C4
  claim: The :where() pseudo-class always scores (0,0,0).
  source: S1
  evidence: "always has a specificity of (0,0,0)"

- id: C5
  claim: The precedence of a layer beats the specificity of a selector.
  source: S2
  evidence: "the precedence of a layer always beats the specificity of a selector"

## Sources

- [S1] Specificity. web.dev. https://web.dev/learn/css/specificity . License: CC-BY-4.0. Accessed 2026-11-23.

- [S2] Cascade layers are coming to your browser. Chrome Developers. https://developer.chrome.com/blog/cascade-layers . License: CC-BY-4.0. Accessed 2026-11-23.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: web.dev, Specificity; Chrome Developers, Cascade layers are coming to your browser. CC-BY-4.0 (https://web.dev/learn/css/flexbox). Copyright Google LLC. web.dev text is CC BY 4.0. CC-BY-4.0 (https://developers.google.com/site-policies). Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License. Copyright Google LLC. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
