CSS view-transition-name Property

The CSS view-transition-name property assigns an identifier to an element so the browser can track its visual representation during a view transition.

By matching transition names between old and new document states, the browser can animate changes in an element's position, size, and appearance. The property works with the View Transition API, the @view-transition at-rule, and generated view transition pseudo-elements.

The property does not start a transition by itself. A view transition must be initiated through a supported mechanism, such as document.startViewTransition() or an eligible cross-document navigation.

view-transition-name Syntax

The view-transition-name property accepts none, a custom identifier, or match-element.

Basic Syntax

.card {
  view-transition-name: card-one;
}

Default Value

.card {
  view-transition-name: none;
}

Automatic Element Matching

.card {
  view-transition-name: match-element;
}

Different Names for Different Elements

.first-card {
  view-transition-name: first-card;
}
.second-card {
  view-transition-name: second-card;
}

CSS-Wide Keywords

.card {
  view-transition-name: initial;
}
.card {
  view-transition-name: inherit;
}
.card {
  view-transition-name: unset;
}
.card {
  view-transition-name: revert;
}
.card {
  view-transition-name: revert-layer;
}

Invalid Values

.card {
  view-transition-name: "card-one";
}
.card {
  view-transition-name: card-one, card-two;
}
.card {
  view-transition-name: 123card;
}

Custom transition names use unquoted CSS identifiers. A declaration accepts one name rather than a comma-separated list. Identifiers beginning with a digit require valid CSS escaping.

Note: The identifiers none, match-element, and CSS-wide keywords cannot be used as ordinary custom transition names.

Property Values

Value Description
none Excludes the element from having its own named view transition representation. This is the initial value.
<custom-ident> Assigns a custom identifier that the browser uses to match the element's visual representation between document states.
match-element Assigns an automatically generated identity-based transition name to the element for same-document transitions.

Property Characteristics

Characteristic Value
Initial value none
Inherited No
Applies to All elements
Computed value Specified identifier, none, or an internal identifier for match-element
Animation type Discrete
Percentages Not applicable
Shorthand None
Specification CSS View Transitions Module Level 1 and Level 2

Note: A named element participates in a view transition when the browser captures it as part of an active transition. Assigning a name alone does not cause an animation.

How It Works

View transitions allow the browser to animate between two visual states. The view-transition-name property identifies elements that should have their own transition representations.

Step 1: Create an Element

<div class="card">Animated Card</div>

Step 2: Assign a Transition Name

.card {
  view-transition-name: animated-card;
}

The browser can now identify the card separately from the rest of the document during a view transition.

Step 3: Define Different Visual States

.card {
  width: 180px;
  padding: 20px;
  background-color: #e5eef7;
}
.card.expanded {
  width: 300px;
  background-color: #cce5ff;
}

Step 4: Start the Transition

document.startViewTransition(() => {
  document.querySelector(".card").classList.toggle("expanded");
});

Step 5: Animate Between States

The browser captures the old visual state, applies the DOM update, and captures the new state. It then generates view transition pseudo-elements to animate between the snapshots.

Customize the Transition Duration

::view-transition-group(animated-card) {
  animation-duration: 500ms;
}

This rule changes the animation duration for the named transition group.

Important Distinction

The property identifies the element to track. The View Transition API or navigation mechanism controls when the transition occurs.

The none Value

The none value indicates that an element does not have its own named view transition representation.

Syntax

.card {
  view-transition-name: none;
}

Default Behavior

The initial value is none, so elements do not receive individual transition names unless one is assigned.

Removing a Transition Name

.card {
  view-transition-name: animated-card;
}
.card.no-transition {
  view-transition-name: none;
}

The second rule removes the card's individual transition name.

Does Not Disable All View Transitions

An element without its own transition name can still appear within the captured representation of an ancestor, including the root transition group.

When to Use It

Use none when an element should not be independently tracked during a view transition.

Important Consideration

Setting view-transition-name: none does not disable the View Transition API or prevent other elements from participating in transitions.

Custom Transition Names

Custom identifiers provide explicit names for elements that should be tracked between document states.

Valid Names

.logo {
  view-transition-name: site-logo;
}
.heading {
  view-transition-name: page-heading;
}
.card {
  view-transition-name: featured-card;
}

Invalid Names

.logo {
  view-transition-name: "site-logo";
}
.heading {
  view-transition-name: page heading;
}

Custom names cannot be quoted strings or unseparated sequences of identifiers.

Names Are Case-Sensitive

.card {
  view-transition-name: FeaturedCard;
}

The name FeaturedCard is different from featuredcard.

Matching Names Between States

.thumbnail {
  view-transition-name: product-image;
}
.large-image {
  view-transition-name: product-image;
}

These selectors can represent corresponding elements in different document states. They must not cause two rendered elements to use the same transition name simultaneously within a captured state.

Names and CSS Selectors

::view-transition-group(product-image) {
  animation-duration: 600ms;
}

The transition name appears directly inside the pseudo-element selector, without a leading period.

Naming Recommendations

Choose descriptive names such as site-logo, main-heading, or featured-image to make transition relationships easier to understand.

The match-element Value

The match-element value allows the browser to generate a transition name based on an element's identity.

It is useful when several elements need independent transitions but manually assigning unique names would be inconvenient.

Basic Syntax

.card {
  view-transition-name: match-element;
}

Multiple Elements

<div class="card">First Card</div>
<div class="card">Second Card</div>
<div class="card">Third Card</div>
.card {
  view-transition-name: match-element;
}

Each card receives an automatically generated identity-based transition name rather than sharing a single explicit name.

Useful for Reordering Elements

The value is particularly useful when existing DOM elements move between positions in a list or grid.

JavaScript Example

const list = document.querySelector(".card-list");
document.startViewTransition(() => {
  list.append(list.firstElementChild);
});

The browser can match the same DOM elements before and after they are reordered.

Same-Document Limitation

Automatically generated names based on element identity are intended for same-document transitions. They cannot be used to match elements across separate documents.

Element Identity Matters

Replacing an element with a newly created DOM node does not preserve the original node's identity, even if the replacement has identical markup.

Browser Support

The match-element value is newer than basic custom transition names and may have different browser compatibility.

Important Consideration

Use explicit custom identifiers when matching corresponding elements across documents or when stable, author-defined names are required.

Unique Transition Names

Each independently captured element must have a unique transition name within a document state.

Incorrect: Duplicate Names

.card-one {
  view-transition-name: card;
}
.card-two {
  view-transition-name: card;
}

If both elements participate in the same captured state, the duplicate name causes the view transition to be skipped.

Correct: Unique Names

.card-one {
  view-transition-name: card-one;
}
.card-two {
  view-transition-name: card-two;
}

Automatic Unique Names

.card {
  view-transition-name: match-element;
}

For same-document transitions, match-element can avoid manually assigning individual names to existing elements.

Reusing Names Between States

The same transition name can appear in the old and new states to establish a match between corresponding visual elements.

Important Distinction

Names must be unique within each captured state, not necessarily different between the old and new states.

Shared Styling

When several uniquely named elements need the same transition styles, use view-transition-class rather than assigning them identical transition names.

Matching Elements Between States

The browser uses transition names to associate visual representations captured before and after an update.

Same Name in Both States

.thumbnail {
  view-transition-name: featured-image;
}
.full-image {
  view-transition-name: featured-image;
}

If the thumbnail appears in the old state and the full image appears in the new state, the browser can match their transition representations.

Old and New Snapshots

The browser creates snapshots for the named element in the relevant states. When both snapshots exist, the transition can animate between them.

Element Appears Only in the New State

If a named element appears only in the new state, the browser can animate its introduction using the new-state snapshot.

Element Appears Only in the Old State

If a named element exists only in the old state, the browser can animate its removal using the old-state snapshot.

Changing Position

.card {
  view-transition-name: moving-card;
}
.card.moved {
  margin-left: 100px;
}

When the class change occurs inside an active view transition, the browser can animate the card between its old and new positions.

Changing Size

.card {
  view-transition-name: expanding-card;
  width: 180px;
}
.card.expanded {
  width: 300px;
}

The browser can animate the transition group's dimensions between the captured states.

Important Consideration

The browser animates captured visual representations. It does not automatically interpolate every CSS property on the original DOM element.

View Transition Pseudo-Elements

During a view transition, the browser creates a temporary pseudo-element tree representing the old and new visual states.

::view-transition

::view-transition {
  pointer-events: none;
}

Represents the root of the view transition pseudo-element tree.

::view-transition-group()

::view-transition-group(featured-card) {
  animation-duration: 500ms;
}

Represents the transition group associated with the specified name.

::view-transition-image-pair()

::view-transition-image-pair(featured-card) {
  isolation: isolate;
}

Contains the old and new snapshot pseudo-elements for the named transition.

::view-transition-old()

::view-transition-old(featured-card) {
  animation-timing-function: ease-in;
}

Represents the old-state snapshot.

::view-transition-new()

::view-transition-new(featured-card) {
  animation-timing-function: ease-out;
}

Represents the new-state snapshot.

Wildcard Selectors

::view-transition-group(*) {
  animation-duration: 400ms;
}

The wildcard selects all generated transition groups.

The root Transition Group

::view-transition-group(root) {
  animation-duration: 300ms;
}

The special root transition group represents the document's root view transition capture.

Important Consideration

View transition pseudo-elements exist only during an active transition. Their styles do not directly modify the original DOM elements.

Relationship to view-transition-class

The view-transition-name and view-transition-class properties are complementary.

Transition Names Identify Elements

.first-card {
  view-transition-name: first-card;
}
.second-card {
  view-transition-name: second-card;
}

Transition Classes Share Styles

.card {
  view-transition-class: card;
}

Style by Name

::view-transition-group(first-card) {
  animation-duration: 700ms;
}

This rule targets one specific transition group.

Style by Class

::view-transition-group(.card) {
  animation-duration: 500ms;
}

This rule targets all generated transition groups associated with the card transition class.

Combined Example

.first-card {
  view-transition-name: first-card;
  view-transition-class: card;
}
.second-card {
  view-transition-name: second-card;
  view-transition-class: card;
}
::view-transition-group(.card) {
  animation-duration: 500ms;
}

Important Distinction

Transition names must be unique within each captured state. Transition classes can be shared by multiple elements.

Same-Document View Transitions

Same-document view transitions animate changes within a single page, including layout updates, element movement, and content changes.

HTML Example

<button type="button" id="move-card">Move Card</button>
<div class="card-container">
  <div class="card">Animated Card</div>
</div>

CSS Example

.card-container {
  display: flex;
  justify-content: flex-start;
}
.card-container.moved {
  justify-content: flex-end;
}
.card {
  width: 150px;
  padding: 20px;
  background-color: #e5eef7;
  view-transition-name: moving-card;
}
::view-transition-group(moving-card) {
  animation-duration: 600ms;
}

JavaScript Example

const button = document.querySelector("#move-card");
const container = document.querySelector(".card-container");
button.addEventListener("click", () => {
  const update = () => container.classList.toggle("moved");
  if (document.startViewTransition) {
    document.startViewTransition(update);
  } else {
    update();
  }
});

How It Works

The browser captures the card before and after the layout change. Because the card retains the same transition name, its visual representation can animate between the two positions.

Fallback Behavior

If the View Transition API is unavailable, the layout changes immediately without a view transition.

Important Consideration

Only one same-document view transition can be active at a time for a document. Starting another transition may skip an existing transition.

Cross-Document View Transitions

Cross-document view transitions can animate navigation between eligible pages on the same origin.

Both documents must opt in to eligible navigation transitions using the @view-transition at-rule.

Enable Navigation Transitions

@view-transition {
  navigation: auto;
}

First Page

.product-thumbnail {
  view-transition-name: product-image;
}

Second Page

.product-large-image {
  view-transition-name: product-image;
}

Matching Names

The matching product-image names allow the browser to associate the visual representations across the two documents.

Customize the Transition

::view-transition-group(product-image) {
  animation-duration: 600ms;
}

Navigation Requirements

Cross-document transitions require browser support, eligible same-origin navigation, and appropriate document opt-in.

match-element Limitation

The match-element value cannot establish matching element identities between separate documents. Use explicit custom transition names instead.

Important Consideration

Navigation transitions are progressive enhancements. Links and navigation should remain functional when transitions are unsupported.

Inheritance

The view-transition-name property is not inherited. Child elements do not automatically receive their parent's transition name.

Parent Declaration

.parent {
  view-transition-name: parent-card;
}

Child Declaration

.parent .child {
  view-transition-name: child-card;
}

The child has its own transition name.

Explicit Inheritance

.parent {
  view-transition-name: parent-card;
}
.parent .child {
  view-transition-name: inherit;
}

The child inherits the parent's computed name. If both elements participate in the same captured state, this can cause a duplicate-name conflict.

Restore the Initial Value

.example {
  view-transition-name: initial;
}

This restores the initial value of none.

Using unset

.example {
  view-transition-name: unset;
}

Because the property is not inherited, unset behaves like initial.

Important Consideration

Avoid explicitly inheriting transition names onto independently captured descendants unless the resulting name assignments are valid and intentional.

Practical Examples

Animated Site Logo

.site-logo {
  view-transition-name: site-logo;
}
::view-transition-group(site-logo) {
  animation-duration: 500ms;
}

Animated Page Heading

.page-heading {
  view-transition-name: page-heading;
}
::view-transition-group(page-heading) {
  animation-duration: 400ms;
}

Expanding Card

.card {
  view-transition-name: expanding-card;
  width: 180px;
}
.card.expanded {
  width: 300px;
}

Moving Navigation Indicator

.navigation-indicator {
  view-transition-name: active-indicator;
}

When the indicator moves between positions during a view transition, the browser can animate its visual representation.

Product Image Transition

.product-image {
  view-transition-name: product-image;
}

The same name can identify corresponding product images in old and new states.

Automatically Match List Items

.sortable-item {
  view-transition-name: match-element;
}

Existing DOM elements can be tracked individually when reordered during a same-document transition.

Shared Card Styling

.card-one {
  view-transition-name: card-one;
  view-transition-class: card;
}
.card-two {
  view-transition-name: card-two;
  view-transition-class: card;
}
::view-transition-group(.card) {
  animation-duration: 500ms;
}

Remove a Transition Name

.card.no-transition {
  view-transition-name: none;
}

This removes the card's individual transition name without disabling other view transitions.

view-transition-name Example

This interactive example demonstrates how view-transition-name allows the browser to animate an element between two positions.

Click the button to move the card from one side of its container to the other. In supporting browsers, the card moves smoothly between the captured positions.

HTML Example

<div class="transition-demo">
  <button type="button" class="transition-button">Move Card</button>
  <div class="transition-container">
    <div class="transition-card">Animated Card</div>
  </div>
</div>

CSS Example

.transition-button {
  margin-bottom: 15px;
  padding: 10px 20px;
  color: #fff;
  background-color: #0066cc;
  border: 0;
  cursor: pointer;
}
.transition-container {
  display: flex;
  justify-content: flex-start;
  min-height: 110px;
  padding: 10px;
  background-color: #f5f5f5;
  border: 1px solid #ccc;
}
.transition-container.moved {
  justify-content: flex-end;
}
.transition-card {
  display: grid;
  place-items: center;
  width: 140px;
  min-height: 90px;
  padding: 10px;
  background-color: #e5eef7;
  border: 2px solid #0066cc;
  border-radius: 6px;
  text-align: center;
  view-transition-name: moving-card;
}
::view-transition-group(moving-card) {
  animation-duration: 600ms;
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(moving-card) {
    animation-duration: 0.01ms;
  }
}

JavaScript Example

const demo = document.querySelector(".transition-demo");
const button = demo.querySelector(".transition-button");
const container = demo.querySelector(".transition-container");
button.addEventListener("click", () => {
  const update = () => container.classList.toggle("moved");
  if (document.startViewTransition) {
    document.startViewTransition(update);
  } else {
    update();
  }
});
Browser Result
Animated Card

Understanding the Results

The card uses view-transition-name: moving-card to identify its visual representation during the transition.

Changing the Layout

Clicking the button toggles the moved class, changing the container's alignment from left to right or right to left.

Capturing the States

The browser captures the card's old position, applies the layout change, and captures its new position.

Animating the Transition

The generated transition group animates between the two positions over 600 milliseconds.

Fallback Behavior

If the View Transition API is unsupported or reduced motion is requested, the card changes position without starting a view transition.

Experiment With the Duration

::view-transition-group(moving-card) {
  animation-duration: 1000ms;
}

The transition now takes one second.

Experiment With the Transition Name

.transition-card {
  view-transition-name: featured-card;
}
::view-transition-group(featured-card) {
  animation-duration: 600ms;
}

The animation continues to work because the property value and pseudo-element selector use the same name.

Experiment With none

.transition-card {
  view-transition-name: none;
}

The card no longer receives its own named transition group and instead changes as part of the surrounding document representation.

Accessibility Considerations

The view-transition-name property affects visual transitions. It does not change document semantics, reading order, or the accessibility tree.

Respect Reduced Motion Preferences

Provide a reduced-motion alternative for users who prefer less animation.

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

Keep Navigation Functional

Links and navigation should work normally when view transitions are unsupported.

Maintain Keyboard Focus

DOM updates should preserve or appropriately restore keyboard focus, especially when interactive elements are replaced.

Avoid Excessive Motion

Large movements, rapid scaling, and repeated transitions can be distracting or uncomfortable.

Keep Content Readable

Important content should remain understandable before, during, and after transitions.

Avoid Unnecessary Delays

Long transitions can make interfaces feel slow and may interfere with repeated user actions.

Test Without Transitions

Verify that layout updates and navigation remain usable when view transitions are unavailable.

Common Mistakes

Using Duplicate Names

.card-one,
.card-two {
  view-transition-name: card;
}

If both cards are captured in the same document state, the duplicate transition name causes the transition to be skipped.

Using Quotation Marks

.card {
  view-transition-name: "card";
}

Transition names are CSS identifiers, not strings.

Using Multiple Names

.card {
  view-transition-name: card-one, card-two;
}

The property accepts one transition name per element.

Assuming the Property Starts Transitions

Assigning a transition name does not automatically animate DOM changes.

Confusing Names With Classes

Use view-transition-name to identify individual transitions and view-transition-class to share styling among groups.

Using the Wrong Pseudo-Element Selector

::view-transition-group(.moving-card) {
  animation-duration: 500ms;
}

This selects a transition class named moving-card, not a transition group named moving-card. Omit the period when selecting by transition name.

Using match-element Across Documents

The match-element value does not establish matching identities between separate documents.

Replacing DOM Nodes Unexpectedly

Identity-based matching with match-element requires the same DOM element to remain identifiable between states.

Ignoring Browser Support

Provide fallbacks because view transition support varies among browsers and versions.

Ignoring Reduced Motion Preferences

Reduce or disable substantial motion when the user requests reduced motion.

Important Considerations

Keep the following points in mind when using view-transition-name:

  • The property identifies elements for individual view transition representations.
  • Its initial value is none.
  • The property is not inherited.
  • It accepts none, a custom identifier, or match-element.
  • Custom identifiers are unquoted CSS names.
  • Custom identifiers are case-sensitive.
  • Each element can have one transition name.
  • Transition names must be unique within each captured document state.
  • Duplicate names among participating elements can cause a transition to be skipped.
  • The same name can appear in old and new states to establish a match.
  • Matching names allow the browser to associate corresponding visual representations.
  • The match-element value generates identity-based transition names.
  • The match-element value is intended for same-document transitions.
  • Explicit custom names are needed for matching elements across documents.
  • The property does not start transitions automatically.
  • Same-document transitions can be started using document.startViewTransition().
  • Eligible cross-document transitions require appropriate browser support and document opt-in.
  • The browser creates temporary pseudo-elements during active transitions.
  • Transition pseudo-elements represent captured visual states.
  • Name-based pseudo-element selectors target individual transition groups.
  • The special root transition group represents the root document capture.
  • The view-transition-class property allows shared transition styling.
  • Transition classes can be shared even when transition names must be unique.
  • Setting none removes an element's individual transition name.
  • Setting none does not disable all view transitions.
  • View transitions animate captured visual representations rather than every underlying CSS property.
  • Custom pseudo-element animations can override default browser animations.
  • Test transitions involving changes in position, size, and layout.
  • Provide fallbacks for unsupported browsers.
  • Respect reduced-motion preferences.
  • Maintain keyboard focus and accessibility during DOM updates.
  • Keep navigation and content usable without animations.

Browser Support

The CSS view-transition-name property has varying browser support. Basic named view transitions are available in modern browsers, but support for individual features such as match-element and cross-document transitions may differ.

For current compatibility information, visit Can I Use? and search for view-transition-name.

Standard Declaration

.card {
  view-transition-name: animated-card;
}

CSS Feature Detection

@supports (view-transition-name: animated-card) {
  .card {
    view-transition-name: animated-card;
  }
}

JavaScript Feature Detection

if (document.startViewTransition) {
  document.startViewTransition(updateContent);
} else {
  updateContent();
}

This checks whether the same-document View Transition API is available.

Feature Detection for match-element

@supports (view-transition-name: match-element) {
  .card {
    view-transition-name: match-element;
  }
}

Progressive Enhancement

Build interfaces that function without view transitions, then add named transitions when the browser supports the required features.

Vendor Prefixes

The standard property uses the unprefixed view-transition-name name. Experimental implementations may differ, so consult current browser documentation when supporting older versions.

Testing Recommendations

Test named element matching, duplicate-name handling, same-document updates, cross-document navigation, and reduced-motion behavior. Verify that the interface remains usable without view transitions.

Specifications

The view-transition-name property is defined in CSS View Transitions Module Level 1, with additional features developed in CSS View Transitions Module Level 2.

CSS View Transitions Module Level 1 - view-transition-name

CSS View Transitions Module Level 2

These specifications define how elements are identified, captured, and matched during view transitions.

For additional documentation and examples, consult MDN Web Docs.

MDN Web Docs: view-transition-name