CSS Specificity Calculator
Understand how browsers calculate the weight of CSS selectors.
CSS Specificity Calculator
Compare CSS selectors using the browser’s A-B-C specificity tuple.
Enter one selector per line to compare them. `!important` is shown separately because it changes cascade precedence.
div#header .nav-link:hoverStrongestCalculated report
1-2-1 div#header .nav-link:hover
Features
- Counts IDs, classes, attributes, pseudo-classes, elements, and pseudo-elements
- Handles modern :is(), :not(), :has(), and zero-weight :where() arguments
- Compares multiple selectors and highlights the strongest tuple
- Explains !important, inline styles, cascade layers, and source order
Cascade reminder: origin, importance, layers, inline styles, specificity, and source order all participate in deciding the winning declaration.
CSS specificity FAQ
How is CSS specificity compared?
The browser compares IDs, then classes/attributes/pseudo-classes, then elements/pseudo-elements from left to right. A higher earlier column wins.
How do :is(), :not(), and :has() affect specificity?
These functional pseudo-classes take the specificity of their most specific argument. :where() is the exception and always contributes zero.
Does !important increase specificity?
No. !important changes cascade precedence before the specificity comparison. Between two important declarations, specificity still resolves the tie.