October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk2 min

CSS `:where()` Makes Flexible Selectors Possible

CSS :where() preserves selector matching logic while contributing zero specificity, making flexible baseline rules easier to override.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How :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
Sale
HTML and CSS: Design and Build Websites
  • 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.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

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
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • 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.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.