ποΈ CSS Specificity Calculator β Selector Weight
Paste one selector to see its specificity tuple. IDs outweigh classes, and classes outweigh elements. :where() adds no weight; :is() and :not() use the most specific argument.
What this tool does
The specificity calculator scores a single CSS selector as a four-part tuple: inline styles, IDs, classes/attributes/pseudo-classes, and elements/pseudo-elements. Comparing tuples from left to right shows which rule wins when two selectors target the same element.
It understands modern pseudo-classes such as :where(), which contributes no specificity, and :is() and :not(), which take the specificity of their most specific argument. That makes it more useful than counting characters in the selector.
When to use it
- Explaining why a component style is being overridden.
- Choosing between an ID selector and a class-based approach.
- Checking the effect of :is(), :not() and :where() on a selector's weight.
- Reviewing a stylesheet for unnecessarily high specificity.
How it works
- Enter a single selector, not a full rule with braces.
- Press Calculate specificity. The tuple is inline styles, IDs, classes/attributes/pseudo-classes, then elements/pseudo-elements.
- Compare tuples left to right. A higher number in an earlier column wins.
Worked example
The selector #main .item scores (0,1,1,0): one ID and one class. The selector nav .menu > a:hover scores (0,0,2,2): one class for .menu, one pseudo-class for :hover, and two element selectors for nav and a. The first selector wins because its ID column is higher, regardless of the later columns.
- #main .item scores (0, 1, 1, 0).
- nav .menu > a:hover scores (0, 0, 2, 2) because :hover is a pseudo-class.
- button scores (0, 0, 0, 1).
Accuracy and limitations
- Enter one selector, not a full rule with declarations or braces. Selector lists are parsed separately and should be checked one at a time.
- The score does not model cascade layers, !important, source order or inherited styles, which can override specificity in practice.
- Inline style attributes are represented by the first tuple column only when the selector itself is written as inline style; a normal stylesheet selector cannot outrank an inline attribute.
Privacy and data handling
Selectors are parsed locally in the browser. No stylesheet or page content is uploaded.
Frequently asked questions
Does !important change the tuple?
No. !important is a separate cascade layer and is not part of the specificity tuple. Remove it from the selector before scoring.
How are :is() and :where() handled?
:where() contributes nothing. :is() and :not() contribute the highest specificity among their arguments, not the sum of every argument.
Are commas supported?
Enter one selector. If you paste a comma-separated list, only the first selector is scored and a note is shown.
Does :where() really add nothing?
Correct. :where() always contributes zero specificity, while :is() and :not() adopt the specificity of their most specific argument.
Why does my rule still lose with a higher tuple?
Check for !important, cascade layers, inline styles or a later rule with equal specificity. Specificity is only one part of the cascade.
Related tools
More Design tools βColor Contrast Checker
Measure WCAG contrast between two hex colors for text and interface graphics.
HSL to Hex Converter
Convert between HSL and hexadecimal color formats privately.
Aspect Ratio Calculator
Solve width, height and simplified aspect ratios without breaking proportions.
CSS Gradient Generator
Generate CSS linear and radial gradients with live preview and copy-ready code.