CSS Selector Specificity Comparator
Compare the specificity of two selectors and see exactly where every point comes from.
What this tool does
Enter two selectors and press Compare to get each (A,B,C) triple, the first differing component, and a complete node contribution tree. Everything is computed in your browser; nothing is sent or stored.
Note: specificity is not the cascade. This tool does not execute selectors, match a DOM, or predict which rule wins; it only computes specificity within the supported subset below.
Supported grammar subset (complete list)
Only the following grammar is supported; anything outside the subset is reported as unsupported or a syntax error, which is not a claim about browser CSS validity.
- Type and universal: an ident ([A-Za-z_][A-Za-z0-9_-]*) or *, only at the start of a compound.
- Simple selectors: #id, .class, [attr] (attribute presence only, a bare ident inside the brackets).
- Ordinary pseudo-classes (single colon): hover, focus, focus-visible, focus-within, active, checked, disabled, enabled, root, empty, first-child, last-child, only-child.
- Functional pseudo-classes: :is(...), :not(...), :where(...), whose argument is a comma-separated list of complex selectors (1–8 branches, functions nested at most 4 deep).
- Pseudo-elements (double colon): before, after, first-line, first-letter, only at the end of the final compound of the top-level selector, and only after a type, universal, or simple selector.
- Combinators: whitespace (descendant), >, +, ~. A top-level comma is unsupported.
- Each field is limited to 1024 UTF-16 units of raw text; the core never trims or normalizes your input, and the raw text is retained exactly.
- Scoring: ID=(1,0,0); class/attribute/ordinary pseudo-class=(0,1,0); type/pseudo-element=(0,0,1); *=(0,0,0). :is/:not take the lexicographically greatest branch (not a componentwise maximum; ties do not multiply); :where always contributes 0, but its children must still parse and their scores remain visible in the tree. Comparison inspects A, then B, then C; components never carry.
Not compared yet.
Error summary
Comparison result
First differing component:
Left contribution tree
Right contribution tree
Each line: node kind, the raw source slice, and that node's (A,B,C). Selector and compound nodes sum the contributions of their children.