# ::view-transition

> The `::view-transition` CSS pseudo-element is the root of the view transition overlay that contains all snapshots.

## How do view transitions work in CSS?

The pseudo-element that is the root of the tree of pseudo-elements created during a view transition. It sits above all page content and contains `::view-transition-group()` for every captured element.

- Topic: View Transitions
- Type: pseudo-element
- Browser support: Chrome 109+, Chrome Android 109+, Edge 109+, Firefox 144+, Firefox Android 144+, Safari 18+, Safari iOS 18+

## Example

Wrong:

```js
document.startViewTransition(() => {
  updateDOM();
});
```

Right:

```js
if (!document.startViewTransition) {
  updateDOM();
} else {
  document.startViewTransition(() => updateDOM());
}
```

Without the check, browsers lacking view transitions throw an error and the DOM never updates.

## Common mistakes

- Expecting `::view-transition` styles to show outside a running transition.

## Key points

- Code checks for `document.startViewTransition` and updates the DOM directly when it's missing.
- Page navigations opt in with `@view-transition { navigation: auto; }` instead of a JavaScript router hack.
- Motion is removed or reduced inside `@media (prefers-reduced-motion: reduce)`.

## Interview questions

### Do view transitions work across page navigations?

Yes, for same-origin navigations when both pages opt in with `@view-transition { navigation: auto; }`.

### What pseudo-elements does a view transition create?

`::view-transition` holds a `::view-transition-group()` per name, each with a `::view-transition-image-pair()` that contains `::view-transition-old()` and `::view-transition-new()`.

## Related cards

- [document.startViewTransition()](https://wonderium.dev/js/start-view-transition.md)
- [::view-transition-group()](https://wonderium.dev/css/view-transition-group.md)
- [view-transition-name](https://wonderium.dev/css/view-transition-name.md)
- [:active-view-transition](https://wonderium.dev/css/active-view-transition.md)
- [MPA](https://wonderium.dev/web/mpa.md)

---

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