# :where()

> The `:where()` CSS pseudo-class groups multiple selectors to apply the same styles to elements matching any of them, without increasing specificity.

## Why use :where() in CSS instead of :is()?

The pseudo-class that matches elements based on a selector list without adding specificity. It's useful for applying styles to multiple elements while maintaining low specificity, preventing conflicts with other styles.

- Topic: Pseudo Classes
- Type: pseudo-class
- Browser support: Chrome 88+, Chrome Android 88+, Edge 88+, Firefox 78+, Firefox Android 79+, Safari 14+, Safari iOS 14+

## Example

Wrong:

```css
ul[class],
ol[class] {
  list-style: none;
  padding: 0;
}
```

Right:

```css
:where(ul, ol)[class] {
  list-style: none;
  padding: 0;
}
```

Only the `[class]` part counts now, so a single class can override this reset without extra specificity.

## Common mistakes

- Wrapping component styles in `:where()` and then losing to a plain element rule.
- Thinking `:where()` changes which elements match, while it only changes specificity.

## Key points

- Resets and library defaults are wrapped in `:where()` so any user selector overrides them.
- Code does not use `:where()` where styles must win over others, since it adds no specificity.

## Interview questions

### What is the specificity of :where()?

Always zero. Nothing inside `:where()` counts, though selectors outside it still do.

### Should I use :where() or @layer for low-priority styles?

Both work. `:where()` lowers one selector's specificity, while `@layer` lowers a whole group of rules at once.

## Related cards

- [:is()](https://wonderium.dev/css/is.md)
- [Specificity](https://wonderium.dev/css/specificity.md)
- [@layer](https://wonderium.dev/css/layer.md)
- [:not()](https://wonderium.dev/css/not.md)
- [Cascade Principle](https://wonderium.dev/css/cascade-principle.md)

---

- Level: [CSS](https://wonderium.dev/css.md)
- HTML version: https://wonderium.dev/css/where
- Last updated: 2026-11-25
