Calculate CSS specificity and see exactly where it comes from. Enter one or more selectors and each is broken into labeled parts — IDs, classes and pseudo-classes, elements and pseudo-elements — with its (a, b, c) score, and the selector that wins is highlighted. Modern selectors like :is(), :not(), :has(), :where() and :nth-child(… of …) follow the current spec. It's free, runs in your browser, and nothing you paste is sent anywhere.
| Selector part | Adds |
|---|---|
| #id | (1, 0, 0) |
| .class, [attr], :hover | (0, 1, 0) |
| div, ::before | (0, 0, 1) |
| *, combinators, :where() | (0, 0, 0) |
| :is(), :not(), :has() | Most specific argument |
Count IDs into a, classes/attributes/pseudo-classes into b, and elements/pseudo-elements into c. Compare a first, then b, then c — the higher wins.
No. Columns never carry over: (1, 0, 0) beats (0, 11, 0).
That of the most specific selector inside it. :where() is always zero, which makes it useful for overridable defaults.
The rule that appears later in the stylesheet wins.
Inline styles beat any selector. !important declarations beat normal ones, including inline styles. Cascade layers are compared before specificity.
No. Selectors are parsed in your browser.
Specificity is a three-part weight, written (a, b, c) and compared column by column: a counts ID selectors; b counts classes, attribute selectors and pseudo-classes; c counts type selectors and pseudo-elements. The universal selector and combinators add nothing. The calculator tokenizes each selector itself rather than using a regex, so brackets, quoted attribute values and escaped characters don't confuse it, and selector lists are split only on commas at the top level. It follows Selectors Level 4 for the functional pseudo-classes: :where() always contributes zero; :is(), :not() and :has() contribute the specificity of the most specific selector in their argument list rather than counting as a pseudo-class; :nth-child(An+B of S) counts as one pseudo-class plus the most specific selector in S. The legacy single-colon pseudo-elements :before, :after, :first-line and :first-letter are counted as pseudo-elements. Each part is shown with what it adds, and the highest-specificity selector in the list is highlighted, with ties marked, since source order decides those.