CSS @view-transition At-Rule

Beginner
3 examples
Updated: Nov 2026

Definition and Usage

The @view-transition at-rule opts the document into the View Transitions API for navigations. Use it with view-transition-name to animate shared elements between pages or states.

CSS Syntax

syntax.css
@view-transition {
  navigation: auto;
}

Key Parts

PartPurposeTry it
navigation: autoEnable cross-document transitions when possibleTry it
navigation: noneDisable automatic cross-document transitionsTry it
with namesPair with view-transition-name on elementsTry it

CSS Examples

Enable auto navigation transitions

example.css
@view-transition {
  navigation: auto;
}
Try It Yourself

Name a shared element

example.css
.hero {
  view-transition-name: hero;
}
Try It Yourself

Browser Support

@view-transition is a modern CSS at-rule.

✓ Modern CSS

@view-transition

Check current browsers before relying on advanced behavior.

90% Modern browsers
Google Chrome Recent
Full support
Mozilla Firefox Recent
Full support
Apple Safari Recent
Full support
Microsoft Edge Recent
Full support
@view-transition Modern support

Bottom line: Use progressive enhancement. Keep a readable fallback when a browser ignores the at-rule.

Frequently Asked Questions

It opts the document into view transitions for navigations so pages can animate between states.
Same-document transitions often use the View Transitions API in JS. Cross-document can start from this at-rule.
A unique name that links an element across the old and new states for a morphing animation.
Chromium leads; Safari and Firefox are catching up. Keep non-animated fallbacks.
Yes. Target ::view-transition-old(*) and ::view-transition-new(*) pseudo-elements.

Next: Media Queries

Adapt layouts to viewport and device conditions.

Media Queries tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

3 people found this page helpful