# &

> The `&` CSS nesting selector refers to the parent rule when styles are nested inside each other.

## How does the & nesting selector work in native CSS?

The selector that explicitly references the parent selector inside nested rules. Allows writing related styles inside one rule, such as `&:hover` or `.dark &`, without preprocessors. Native nesting reduces repetition and keeps styles of one component together.

- Topic: Selectors
- Type: selector
- Browser support: Chrome 120+, Chrome Android 120+, Edge 120+, Firefox 117+, Firefox Android 117+, Safari 17.2+, Safari iOS 17.2+

## Example

Wrong:

```css
.card {
  &__title {
    font-weight: 700;
  }
}
```

Right:

```css
.card {
  & .title {
    font-weight: 700;
  }
  &:hover {
    outline: 1px solid;
  }
}
```

Native nesting can't join strings into new class names, so use a real class and keep `&` for states.

## Common mistakes

- Copying `&__title` or `&-suffix` from Sass, which native CSS doesn't support.
- Higher specificity than expected, because `&` acts like `:is()` of the parent list.

## Key points

- Suffix selectors like `&:hover` and `&.active` keep the `&` with no space.
- Nesting stays shallow, usually one or two levels, to keep specificity low.
- No Sass-only string joins like `&__title` are used; native CSS can't build class names.

## Interview questions

### Is `&` required in native CSS nesting?

No, a nested `.title { }` works as a descendant. `&` is needed for suffixes like `&:hover` or `&.active`.

### Can I put `&` after a selector?

Yes, `.dark & { }` inside `.card` means `.dark .card`, which styles the card inside a dark container.

## Related cards

- [:is()](https://wonderium.dev/css/is.md)
- [Specificity](https://wonderium.dev/css/specificity.md)
- [@scope](https://wonderium.dev/css/scope.md)
- [:has()](https://wonderium.dev/css/has.md)
- [@layer](https://wonderium.dev/css/layer.md)

---

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