# view-transition-class

> The `view-transition-class` CSS property assigns a class to view transition snapshots to style them as a group.

## How do I style many view transition elements at once?

The property that applies one or more class names to the pseudo-elements generated for named elements in a view transition. Allows applying the same animation to many elements with a single selector instead of styling each name.

- Topic: View Transitions
- Type: property
- Browser support: Chrome 125+, Chrome Android 125+, Edge 125+, Firefox 144+, Firefox Android 144+, Safari 18.2+, Safari iOS 18.2+

## Example

Wrong:

```css
::view-transition-group(card-1),
::view-transition-group(card-2),
::view-transition-group(card-3) {
  animation-duration: 0.4s;
}
```

Right:

```css
.card {
  view-transition-class: card;
}
::view-transition-group(*.card) {
  animation-duration: 0.4s;
}
```

One class selector styles every card's group, so new cards need no extra rules.

## Common mistakes

- Expecting the class to work on elements without a `view-transition-name`.

## Key points

- Shared styles target `::view-transition-group(*.card)` instead of repeating rules per name.
- Each element still has its own `view-transition-name`; the class doesn't replace it.

## Interview questions

### Can an element have several view transition classes?

Yes. List them separated by spaces, like `view-transition-class: card featured`.

### Is view-transition-class the same as the HTML class attribute?

No. It only applies to view transition pseudo-elements and is unrelated to the `class` attribute.

## Related cards

- [view-transition-name](https://wonderium.dev/css/view-transition-name.md)
- [::view-transition-group()](https://wonderium.dev/css/view-transition-group.md)
- [::view-transition](https://wonderium.dev/css/view-transition.md)
- [document.startViewTransition()](https://wonderium.dev/js/start-view-transition.md)

---

- Level: [CSS](https://wonderium.dev/css.md)
- HTML version: https://wonderium.dev/css/view-transition-class
- Last updated: 2026-11-25
