Course contentsShow
← Web Development
Lesson 443 of 2,9828. Advanced CSS Selectors and FeaturesFree lesson

Specificity Differences: :is() vs :where()

Understand how :is() takes the highest specificity from its arguments while :where() has zero specificity.

Specificity Differences: :is() vs :where()

You'll learn why :is() can unexpectedly boost specificity while :where() never does.

Both :is() and :where() let you group selectors for cleaner code, but they handle specificity very differently—and this matters when CSS rules compete.

How :is() Calculates Specificity

When you use :is(), the selector takes the highest specificity of any selector inside its argument list. Think of it like a team where the strongest player sets the team's rank.

/* :is() takes the specificity of #header (an ID = 1,0,0) */
:is(div, #header, .box) p {
  color: blue;
}

Even though you listed div and .box, the #header ID makes this entire selector have ID-level specificity. That p will win against most class-based rules.

How :where() Calculates Specificity

In contrast, :where() has zero specificity—always. It's like a ghost that groups selectors without adding any weight. Only the selectors outside :where() count.

/* :where() contributes 0,0,0 — only the p (element) counts */
:where(div, #header, .box) p {
  color: red;
}

This has the same specificity as just p (0,0,1), making it easy to override.

When to Use Which

Use :is() when you want normal specificity calculation. Use :where() when you want low-specificity base styles that are easily overridden—perfect for design systems and utility frameworks.

Key Takeaway: :is() adopts the highest specificity from its arguments, while :where() always has zero specificity, making it ideal for creating non-intrusive base styles.