Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Pseudo-elements

The ::view-transition pseudo-elements

Reference for the ::view-transition pseudo-element tree: group, image-pair, old and new, used to style animated changes between page states.

When a view transition runs, the browser takes a snapshot of the old state, updates the DOM, and builds a tree of pseudo-elements on top of the page that animates from the old snapshot to the live new one. ::view-transition is the root of that tree. By styling its parts you change the animation.

The tree is only present while a transition is running, so rules for it have no visible effect at any other time.

CSS
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.6s;
}

Try it

Moving a box with a view transition

Syntax

CSS
::view-transition { }
::view-transition-group(<name>) { }
::view-transition-image-pair(<name>) { }
::view-transition-old(<name>) { }
::view-transition-new(<name>) { }

The tree, from the top:

TEXT
::view-transition
โ””โ”€ ::view-transition-group(name)
   โ””โ”€ ::view-transition-image-pair(name)
      โ”œโ”€ ::view-transition-old(name)
      โ””โ”€ ::view-transition-new(name)

Values

Pseudo-element Description
::view-transition Root overlay that covers the viewport during the transition.
::view-transition-group(name) Moves and resizes between the old and new position. Animates width, height and transform.
::view-transition-image-pair(name) Holds the old and new snapshots and isolates them for blending.
::view-transition-old(name) The captured snapshot of the old state. Fades out by default.
::view-transition-new(name) A live image of the new state. Fades in by default.

The name is the value of view-transition-name; the whole page is called root. Use * to match every name.

Usage notes

  • Animations are plain CSS. Set animation-name, animation-duration and animation-timing-function on these pseudo-elements, or write custom @keyframes.
  • Unique names. Two elements with the same view-transition-name at the same time cancel the transition.
  • Defaults. Without your rules, root cross-fades and named groups move smoothly from their old to their new box.
  • Respect motion preferences. Disable or shorten animations inside @media (prefers-reduced-motion: reduce).
  • Keep it short. The page cannot be clicked while the transition runs, so use short durations.
  • Cross-document transitions opt in with @view-transition { navigation: auto; } and need same-origin pages and a browser that supports them.
  • Debugging. Pause animations in dev tools to inspect the pseudo-element tree.

Browser support

Same-document view transitions work in current Chrome, Edge, Safari and Firefox. Cross-document transitions have narrower support. Always feature-detect document.startViewTransition and provide an instant fallback.