CSS @view-transition At-Rule

The @view-transition at-rule opts a document in to eligible cross-document view transitions.

It enables animated changes between separate same-origin pages when both documents opt in and the browser supports the feature.

Syntax

@view-transition {
  navigation: auto;
}

The navigation descriptor controls cross-document view-transition opt-in. The rule belongs at the top level of the stylesheet, not inside a selector.

How @view-transition Works

When both the outgoing and incoming documents opt in, an eligible same-origin navigation can transition between snapshots of the two pages. The browser manages the transition during navigation.

This is different from the JavaScript document.startViewTransition() API, which starts a transition within a document.

@view-transition {
  navigation: auto;
}
/* Disable cross-document opt-in */
@view-transition {
  navigation: none;
}

auto opts the document in to eligible cross-document transitions. none disables this opt-in. Both documents must opt in for the transition to run.

Navigation Requirements

Cross-document transitions are designed for eligible same-origin, document-to-document navigations. The browser may skip a transition for unsupported navigation types or when the documents do not satisfy the opt-in requirements.

Do not depend on a transition to preserve application state or complete a navigation. Navigation should work normally without the visual effect.

Matching Elements Across Pages

.page-title {
  view-transition-name: page-title;
}

Use a matching view-transition-name in both documents to identify elements that should transition together. Each named element must be unique within a document’s rendered view.

Customizing the Animation

::view-transition-old(root) {
  animation-duration: 250ms;
}
::view-transition-new(root) {
  animation-duration: 250ms;
}

View-transition pseudo-elements can be styled to adjust animation timing or appearance. Custom styles affect the transition when it occurs, not the underlying page navigation.

Reduced Motion and Fallbacks

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 0.01ms;
  }
}

Keep navigation usable when transitions are unavailable, and respect reduced-motion preferences. A cross-document transition may be skipped without an error.

@view-transition Example

Add the following CSS to both page-a.html and page-b.html on the same origin.

HTML on page A

<a href="page-b.html">Open Page B</a>

HTML on page B

<a href="page-a.html">Return to Page A</a>

CSS on both pages

@view-transition {
  navigation: auto;
}
h1 {
  view-transition-name: page-heading;
}
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 300ms;
}

Browser Preview: Test by navigating between two separate same-origin pages in a supporting browser. A single embedded Browser Result cannot reproduce a cross-document navigation reliably.

Browser Support

Cross-document view transitions are not available in every browser or browser version. Check current compatibility information at Can I Use? . Search for cross-document view transitions, and test on a real same-origin site.

Specifications

Cross-document view transitions are described in the CSS View Transitions Module Level 2 draft.

CSS View Transitions Module Level 2