| SELECTOR | INLINE | ID | CLASS | ELEMENT | WEIGHT |
|---|
// enter any selector and get its exact specificity value
Enter any CSS selector and get its exact specificity score — ID, class, element breakdown shown visually. Compare multiple selectors, free, no signup.
| SELECTOR | INLINE | ID | CLASS | ELEMENT | WEIGHT |
|---|
Enter a selector in the input field — the score and breakdown update in real time as you type. Click any example to load it instantly.
Each token in your selector is colour-coded — IDs in blue, classes in yellow, elements in green. Hover a token to see its contribution.
Use the "Compare Selectors" table to add multiple selectors side-by-side. The winner is highlighted automatically.
!importantCSS specificity is the algorithm browsers use to decide which rule wins when multiple rules target the same element. It is expressed as a four-number score (inline, id, class, element). This tool parses any selector, calculates the exact score, and shows which tokens contribute to each dimension.
Specificity is a four-part score (a, b, c, d): a = inline styles, b = ID selectors, c = class, attribute, and pseudo-class selectors, d = type (element) and pseudo-element selectors. The universal selector * and combinators (>, +, ~) contribute zero. Higher scores win, compared left to right.
Yes. !important is not part of the specificity score — it completely bypasses the cascade for that property, placing it in a separate "important" origin. Two !important declarations are then resolved by specificity, but they always beat non-important declarations regardless of score.
Yes. Pseudo-classes like :hover, :focus, :nth-child(), and :not() all contribute 1 to the class (c) column. The exception is :where(), which always contributes zero specificity by design. :is() and :has() take the specificity of their most specific argument.
Pseudo-elements like ::before, ::after, ::placeholder, and ::first-line each contribute 1 to the element (d) column — the same as a plain HTML tag. Both single-colon legacy syntax (:before) and double-colon modern syntax (::before) are counted the same.
No. Each column is independent and never carries over. A selector with 100 element selectors does not equal one class selector. The columns are compared independently, so (0,0,1,0) always beats (0,0,0,99). There is no numeric ceiling — each column can grow as large as needed.
The universal selector * matches any element but contributes nothing to the specificity score by specification. This makes it useful as a "lower than everything" baseline — perfect for CSS resets that should be overridden by any author rule.
CSS specificity is one of the most commonly misunderstood parts of the cascade. When two rules both target the same element and set the same property, the browser needs a way to decide which one wins. That decision is based entirely on specificity — a score calculated from the structure of each selector.
The score is written as (a, b, c, d). Column a counts inline styles (the style="" attribute), which always trump any stylesheet rule. Column b counts ID selectors (#id). Column c counts class selectors (.class), attribute selectors ([attr]), and pseudo-classes (:hover). Column d counts element type selectors (div, p) and pseudo-elements (::before).
!important as a first resort — it creates a specificity dead end that is hard to escape.:where() to add selectors with zero specificity — ideal for utility and reset layers.