How to use CSS Specificity Calculator
- Enter one selector rule per line, in source order, or choose a Class versus ID or Where and is example. Comma-separated branches become separate candidates.
- Inspect the ID, class-like and type contributions and totals for each branch. Read tuples from left to right rather than as a decimal score.
- Keep the comparison checkbox selected to identify the winning candidate under its equal-cascade assumptions, or clear it to calculate tuples only. Check real matching and cascade rules in your browser before changing a stylesheet.
Example: CSS Specificity Calculator
Compare an ID-plus-class selector with a type-plus-class selector.
Options
- Selector branches
- Enter up to 4,000 characters, 30 top-level branches and 12 nested function levels. Type, universal, ID, class, attribute and supported pseudo-selectors contribute according to the documented grammar; comma branches are independent candidates.
- Tuple and comparison
- Compare ID counts first, then class-like counts, then type counts. The later candidate wins an equal tuple when comparison is enabled. All branches are assumed to match the same element under equal origin, importance, layer and other cascade conditions.
Supported inputs and limits
- At most 4,000 characters, 30 top-level branches and 12 nested function levels.
- Uses ASCII identifiers with type/universal, ID, class, attribute selectors and descendant, >, + and ~ combinators.
- Supported functions include :is(), :not(), :where(), :has(), :nth-child(), :nth-last-child(), :nth-of-type(), :nth-last-of-type(), :lang() and :dir(), plus the parser’s selected plain pseudo-classes and pseudo-elements.
- Escapes, namespaces, nesting &, comments, column combinators and shadow syntax are refused.
More details
Nested :has() and unsupported pseudo-element placements are also refused.
Comparison assumes every branch matches the same element with equal cascade conditions; it does not inspect a page, parse a whole stylesheet or resolve a real cascade.
Where your input is processed
This tool does not upload your inputs. See the limits for anything saved on your device.
Specificity settles only one part of the cascade
The comparison assumes the selectors all match the same element under equal origin, layer, importance and other cascade conditions. A larger tuple alone cannot explain a rule from a different cascade layer or an !important declaration. Equal tuples can be decided by source order. Inspect the real matched rules in the browser when diagnosing a style conflict.
Questions about CSS Specificity Calculator
Does :where() add specificity?
No. Its contribution and those of its arguments are zero.
Why does an ID inside :is() count?
The functional pseudo-class uses the largest specificity among its supported selector arguments.
Does the largest tuple always win a real page?
No. Matching, importance, origins, cascade layers and other cascade rules must be resolved before a specificity comparison.