CSS Specificity Calculator

Compare supported selector specificity using editable class, ID, :where and :is examples.

On-device No sign-up Free to use

Inspect input controls

Showing an example. Edit to see your own.

?

One selector rule per line; comma branches are separate candidates. Up to 4,000 characters, 30 branches and 12 nested function levels. ASCII identifiers only; no escapes, namespaces, CSS rules or & nesting.

Processed in your browser. Your inputs stay on this device.

Result

Showing an example.

Compare an ID-plus-class selector with a type-plus-class selector.

Candidate 1 wins the stated comparison; later source order breaks equal specificity.

Loading the tool. Your result will appear here.

https://usefreetools.net/css-specificity-calculator · 20 November 2026

Was this helpful?

How to use CSS Specificity Calculator

  1. 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.
  2. 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.
  3. 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.

You add
Selectors in source order: #main .item div.item; Compare assuming every branch matches with equal origin, importance and layer: true
You get
Candidate 1 wins the stated comparison; later source order breaks equal specificity.

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.

Page updated · Project managed by Tony Hines · Report a problem with CSS Specificity Calculator