In CSS, “zero specificity” means a selector can match elements without adding selector weight to the cascade. The :where() pseudo-class does exactly that: it matches according to its argument, but both :where() and everything inside it contribute zero specificity. That makes it useful for baseline styles and selector filters that should be easy to override.
What zero specificity means in CSS
Specificity is one factor browsers use to decide which applicable CSS declaration wins. A selector with zero specificity can still match elements, and declarations in its rule still participate in the cascade. “Zero” describes only the selector’s specificity contribution; it does not disable the rule.
As an Amazon Associate I earn from qualifying purchases.
The W3C Selectors Level 4 specification defines :where() as having zero specificity regardless of the selectors in its argument. In effect, it lets you add a matching condition without making the rule harder to override.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteHow :where() differs from :is()
:where() and :is() have the same matching functionality, but their specificity differs. :where() always contributes zero. By contrast, :is(), :not(), and :has() take the specificity of the most specific selector in their argument list. The W3C Selectors Level 4 specification describes these rules.
#1 Best Overall
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
| Pseudo-class | Matching role | Specificity contribution |
|---|---|---|
:where() |
Matches according to its selector argument | Always zero, including the argument |
:is() |
Matches according to its selector argument | Specificity of the most specific selector in its argument list |
:not() |
Matches elements that do not match its selector argument | Specificity of the most specific selector in its argument list |
:has() |
Matches elements based on its relative selector argument | Specificity of the most specific selector in its argument list |
Why use a selector that is easy to override?
Use :where() when a rule needs useful selector logic but should remain a flexible baseline rather than a forceful cascade rule. For example, a broad reset or navigation style may need to target elements under particular ancestors while allowing a more specific component rule to take precedence.
The W3C specification illustrates the difference with link rules. A declaration using a:not(:hover) carries specificity from its argument, which can prevent a later nav a rule from taking effect. Writing the condition as a:where(:not(:hover)) keeps the matching logic while leaving the selector’s specificity at zero, so the navigation rule can override it when other cascade factors permit.
Rank #2
This is the practical benefit: you can encode a filter without forcing every later rule to compete against extra selector weight. The specification notes that this is useful for introducing filters while keeping the associated declarations easy to override.
How specificity fits into the full cascade
Zero specificity does not guarantee that another declaration wins. Specificity is only one cascade criterion. The current W3C CSS Cascading and Inheritance Level 5 specification places origin and importance first, then cascade layers and specificity, followed by scope proximity and order of appearance. A declaration can therefore lose or win for reasons other than selector specificity.
Rank #3
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
When debugging an unexpected result, first check whether both declarations apply, then compare their origin and importance, layer, specificity, scope proximity, and order. :where() changes the specificity contribution; it does not bypass the rest of the cascade.
Quick Recap
Best Value
Rank #4
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




