# view()

> The `view()` CSS function creates an anonymous view progress timeline based on element visibility in its scroll container.

## How do I animate elements as they scroll into view with CSS?

The function used with `animation-timeline` that ties animation progress to the visibility of the element itself in the scrollport. Often used to reveal elements as they enter the screen.

- Topic: Animations
- Type: function
- Browser support: Chrome 115+, Chrome Android 115+, Edge 115+, Firefox 159+, Firefox Android 159+, Safari 26+, Safari iOS 26+

## Example

Wrong:

```css
.reveal {
  opacity: 0;
  animation: fade-in linear forwards;
  animation-timeline: view();
}
```

Right:

```css
@keyframes fade-in {
  from { opacity: 0; }
}
.reveal {
  animation: fade-in linear both;
  animation-timeline: view();
  animation-range: entry;
}
```

Opacity lives only in the keyframes, so content stays visible where `view()` isn't supported.

## Common mistakes

- Content stays invisible in unsupported browsers because the base style sets `opacity: 0`.

## Key points

- Reveal effects use `animation-timeline: view()` instead of `IntersectionObserver` and toggled classes.
- `animation-range`, like 'entry', limits the effect to when the element enters.
- Elements aren't hidden outside the animation, so content stays visible without support.
- Motion is removed or reduced inside `@media (prefers-reduced-motion: reduce)`.

## Interview questions

### Does view() replace IntersectionObserver?

For visual effects tied to scrolling, often yes. For logic like lazy loading or analytics, `IntersectionObserver` is still the right tool.

### What arguments does view() take?

An optional axis, like 'block' or 'inline', and an optional inset that adjusts the visible area, like `view(block 20%)`.

## Related cards

- [animation-timeline](https://wonderium.dev/css/animation-timeline.md)
- [animation-range](https://wonderium.dev/css/animation-range.md)
- [scroll()](https://wonderium.dev/css/scroll-function.md)
- [IntersectionObserver](https://wonderium.dev/js/intersection-observer.md)
- [@supports](https://wonderium.dev/css/supports.md)

---

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