Free tools that run in your browser. Use any tool without an account.

Favourites Cart
Sign in
Join free

CSS Specificity Calculator

  • Free
  • Runs in your browser
  • No account needed

Specificity is a three-number tuple (A,B,C). For example, #nav .item li scores (1,1,1). This tool shows each selector's IDs, classes and elements and ranks them instantly as you type. You can copy results and share a link.

Highest specificity
1,2,1 #nav .item a:hover
Each selector (IDs, classes, elements)
1,2,1  #nav .item a:hover
0,0,3  ul li::before
0,3,0  .btn.btn-primary[disabled]
1,0,1  :is(#main, .content) p
0,0,1  :where(#main) p
0,0,4  body > header nav a
Runs in your browser. Your files and values are not sent to us. Report a problem
Advertisement

About the CSS Specificity Calculator

This tool calculates CSS selector specificity in your browser, with no upload and no server storage. You paste selectors (one per line or comma separated) and get a highest specificity result, a per-selector A/B/C breakdown, and a ranked table. The calculator follows the W3C Selectors Level 4 method and shows counts for IDs, classes/attributes/pseudo-classes, and element names or pseudo-elements. Results update instantly as you type; there is no calculate button. You can copy results or generate a share link that reopens the tool with the same input. Developers, testers, students and code reviewers use it to check which rule will win and to debug selector conflicts. The page links to the W3C spec and MDN for learning and browser support details.

How to use it

  1. 1Paste selectors one per line or separated by commas.
  2. 2Edit selectors and watch the A,B,C counts update instantly.
  3. 3View the highest specificity and the ranked table.
  4. 4Copy the result or share a link that reopens with your numbers.
Advertisement

Worked example

Input: #header .nav li, .nav > li.active, body article p Results: Highest specificity: #header .nav li (1,1,1) Ranking table: 1) #header .nav li => (1,1,1) 2) .nav > li.active => (0,2,1) 3) body article p => (0,0,3)

The formula

Specificity is three numbers (A, B, C) compared left to right, as in Selectors Level 4A counts ID selectorsB counts classes, attribute selectors and pseudo-classesC counts element names and pseudo-elementsThe universal selector * and combinators count nothing:is(), :not() and :has() take the highest specificity of the selectors inside them, :where() always counts zero, and :nth-child(An+B of S) counts one pseudo-class plus SInline styles and !important beat all of theseResults update instantly as the visitor types; there is no calculate buttonVisitors can copy the result and share a link that reopens with their numbers

Source: W3C Selectors Level 4, Calculating specificityMDN Web Docs, Specificity and the cascade. Last checked 7 November 2026.

What it is good for

  • Runs entirely in your browser with no uploads.
  • Shows per-selector A,B,C counts and a ranked winner list.
  • Instant updates as you type and copyable share links.
  • Calculates per Selectors Level 4; browser runtime support for some selectors may vary.
  • Inline style and importance rules are outside the A,B,C tuple and are shown as notes.
Advertisement

Questions people ask

How do you calculate specificity?

You count ID selectors for A, classes/attributes/pseudo-classes for B, and element names or pseudo-elements for C. Compare the tuple (A,B,C) left to right. See the W3C Selectors Level 4 for the formal rules.

How does :is() or :not() affect specificity?

:is(), :not(), and :has() take the specificity of their most specific argument. :where() always contributes zero. This tool follows the Selectors Level 4 rules.

Does the universal selector or combinators add specificity?

No. The universal selector * and combinators such as space, >, +, and ~ do not add to specificity. They are ignored when counting A, B and C.

What if two selectors have the same specificity?

If specificity and importance tie, the rule that appears later in the source wins. Layering and origin can still change the result. The tool notes ties in the ranking table.

Does the tool show which rule will win in a real page?

The tool ranks selectors by specificity only. Inline styles and !important are outside the tuple. For real page results, check origin and source order in your browser devtools.

Can I save or share my results?

Yes. You can copy results to the clipboard or generate a share link that reopens the tool with your input. The link preserves the selectors and their numbers.

Help keep every tool free

FreeToolr stays free because people help it grow. Share a tool you like, tell us what to build next, or support us on Ko-fi.

Advertisement
Advertisement