# Universal Selector

> The Universal CSS selector, denoted by the '*' symbol, targets all elements in the document.

## What does the * selector do in CSS?

The selector that targets all elements within a document. Represented by the '*' symbol, it applies styles to every element, useful for applying global styles or resetting default browser styling.

- Topic: Selectors
- Type: selector
- Browser support: Chrome 1+, Chrome Android 18+, Edge 12+, Firefox 1+, Firefox Android 4+, Safari 1+, Safari iOS 1+

## Example

Wrong:

```css
* {
  box-sizing: border-box;
}
```

Right:

```css
*,
*::before,
*::after {
  box-sizing: border-box;
}
```

`*` does not match pseudo-elements, so they need to be listed for the reset to cover them.

## Common mistakes

- Setting `* { margin: 0 }` and then wondering why lists and headings lose spacing.
- Setting `font-size` on `*` breaks inheritance for nested `em` values.

## Key points

- The box-sizing reset includes `*::before` and `*::after`.
- `*` is used only in small resets, not to set fonts or colors on everything.

## Interview questions

### Is the universal selector slow?

Not in practice. Modern engines match it quickly, though deep chains like `.a * .b` can still do extra work.

### Does `*` add specificity?

No, the universal selector has zero specificity, so any other selector beats it.

## Related cards

- [Type Selector](https://wonderium.dev/css/type-selector.md)
- [box-sizing](https://wonderium.dev/css/box-sizing.md)
- [Specificity](https://wonderium.dev/css/specificity.md)
- [:where()](https://wonderium.dev/css/where.md)
- [Selector](https://wonderium.dev/css/selector.md)

---

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