CSS Reference ยท At-rules
The @view-transition at-rule
Reference for the CSS @view-transition at-rule: opt in to animated transitions between pages of the same site with navigation: auto, plus support notes.
The @view-transition at-rule opts a page in to cross-document view transitions. When two pages of the same origin both contain the rule and the user navigates between them, the browser captures the old page, loads the new one, and cross-fades between the two instead of flashing blank. You can then customize that animation with the ::view-transition-* pseudo-elements and view-transition-name.
For transitions inside a single page, you call document.startViewTransition() from JavaScript and do not need this rule.
@view-transition { navigation: auto; }
Try it
A cross-document navigation cannot run inside a sandboxed preview, so this demo shows the same animation machinery on one page: a script-started transition that you can style with the pseudo-elements the at-rule feeds. On real multi-page sites, the at-rule above replaces the script.
Syntax
@view-transition { navigation: auto | none; types: <custom-ident>+ | none; }
It is an at-rule, so initial value, inheritance and animatability do not apply. The initial value of navigation is none.
Syntax and arguments
| Descriptor | Description |
|---|---|
navigation: auto |
Enables a view transition for same-origin navigations (links, back and forward, form submissions). |
navigation: none |
No transition. This is the default. |
types |
Optional list of names that become the transition's types, so CSS can pick different animations with :active-view-transition-type(). |
Usage notes
- Both pages must opt in. The old and the new document each need the rule, and they must be same-origin. Cross-origin navigations never transition.
- Only for fast pages. If the new page takes too long to render, the browser skips the transition. Keep pages light, and consider
<link rel="expect" blocking="render">for key elements. - Name what should move. Elements with the same
view-transition-nameon the old and new page morph into each other. Names must be unique per page. - Redirects and reloads. Only a normal navigation is animated. A reload, or a navigation that crosses origins in a redirect chain, is not.
- Reduced motion. Respect users who prefer less movement by setting
animation: noneon::view-transition-group(*)inside aprefers-reduced-motion: reducequery. - Progressive enhancement. Browsers without support navigate as usual, so no fallback is needed.
Browser support
Supported in Chromium-based browsers and Safari 18.2 or newer. Firefox has not shipped cross-document view transitions at the time of writing, so treat it as an enhancement.
Related
view-transition-nameโ mark an element to animate between statesview-transition-classโ style groups of named elements together@mediaโ wrap motion rules inprefers-reduced-motion- Lesson: View Transitions