CSS view-timeline Property

The CSS view-timeline property creates a named view progress timeline that tracks an element's visibility as it moves through a scroll container.

It is a shorthand for view-timeline-name and view-timeline-axis. The resulting timeline can control CSS animations based on scrolling rather than elapsed time.

View timelines are part of CSS scroll-driven animations. They are useful for revealing content, animating illustrations, and creating effects that respond to an element entering or leaving a scrollport.

view-timeline Syntax

The view-timeline shorthand accepts a timeline name and an optional axis value.

Basic Syntax

.example {
  view-timeline: --reveal;
}

Name and Axis

.example {
  view-timeline: --reveal block;
}

Inline Axis

.example {
  view-timeline: --horizontal inline;
}

Physical Axis

.example {
  view-timeline: --horizontal x;
}

Multiple Timelines

.example {
  view-timeline: --reveal block, --horizontal inline;
}

Equivalent Longhand Properties

.example {
  view-timeline-name: --reveal;
  view-timeline-axis: block;
}

CSS-Wide Keywords

.example {
  view-timeline: initial;
}
.example {
  view-timeline: inherit;
}
.example {
  view-timeline: unset;
}
.example {
  view-timeline: revert;
}
.example {
  view-timeline: revert-layer;
}

Invalid Values

.example {
  view-timeline: reveal;
}
.example {
  view-timeline: --reveal vertical;
}
.example {
  view-timeline: --reveal 50%;
}

Timeline names must use the required dashed identifier syntax, beginning with two hyphens. The values vertical and 50% are not valid timeline axis values.

Property Values

Value Description
none Declares no named view progress timeline.
<dashed-ident> Specifies a custom timeline name beginning with two hyphens, such as --reveal.
block Uses the block axis of the scroll container. This is the default axis.
inline Uses the inline axis of the scroll container.
x Uses the physical horizontal axis.
y Uses the physical vertical axis.
, Separates multiple timeline definitions.

Property Characteristics

Characteristic Value
Initial value none for names and block for axes
Inherited No
Applies to All elements
Computed value The computed values of its longhand properties
Animation type Discrete
Percentages Not applicable
Shorthand for view-timeline-name and view-timeline-axis
Specification Scroll-driven Animations Module Level 1

Note: The view-timeline-inset property can adjust the effective visibility range of a view timeline, but it is not a longhand component of the view-timeline shorthand.

How It Works

A view progress timeline tracks the position of an element, called the subject, relative to the visible area of its nearest ancestor scroll container along the selected axis.

Instead of advancing according to elapsed time, an animation attached to the timeline advances according to the subject's progress through the scrollport.

Step 1: Create a Scroll Container

<div class="scroll-container">
  <div class="spacer"></div>
  <div class="reveal-box">Scroll to reveal</div>
  <div class="spacer"></div>
</div>

Step 2: Make It Scrollable

.scroll-container {
  height: 250px;
  overflow-y: auto;
}
.spacer {
  height: 200px;
}

Step 3: Define a View Timeline

.reveal-box {
  view-timeline: --reveal block;
}

The element defines a named view timeline along the block axis.

Step 4: Create an Animation

@keyframes reveal {
  from {
    opacity: 0.2;
  }
  to {
    opacity: 1;
  }
}

Step 5: Connect the Animation

.reveal-box {
  animation-name: reveal;
  animation-duration: 1s;
  animation-timing-function: linear;
  animation-timeline: --reveal;
}

The animation progresses as the subject moves through the scrollport.

Important Distinction

The view-timeline property defines a timeline. It does not create an animation by itself. An animation must reference the timeline through animation-timeline.

Named View Timelines

A named view timeline uses a dashed identifier beginning with two hyphens.

Basic Timeline Name

.example {
  view-timeline: --reveal;
}

Another Timeline Name

.example {
  view-timeline: --card-progress;
}

Referencing the Timeline

.example {
  view-timeline: --card-progress;
  animation-name: card-reveal;
  animation-duration: 1s;
  animation-timeline: --card-progress;
}

Timeline Scope

Named timelines are resolved according to their scope in the document tree. An element can reference a timeline declared on itself or an eligible element in its timeline lookup scope.

For example, an animation on a child element can reference a timeline defined on an ancestor.

Ancestor Timeline Example

<div class="card">
  <div class="card-content">Animated content</div>
</div>
.card {
  view-timeline: --card-view;
}
.card-content {
  animation-name: fade-in;
  animation-duration: 1s;
  animation-timeline: --card-view;
}

Sibling Timeline References

A sibling element cannot automatically reference another sibling's named timeline. More advanced relationships may require the timeline-scope property.

Naming Recommendations

Use descriptive names such as --image-reveal, --section-progress, or --card-view to make timeline relationships easier to understand.

Timeline Axis Values

The axis determines the direction along which the subject's view progress is measured.

block

.example {
  view-timeline: --reveal block;
}

Uses the block axis of the scroll container. In common horizontal writing modes, this corresponds to vertical scrolling.

inline

.example {
  view-timeline: --reveal inline;
}

Uses the inline axis. In common horizontal writing modes, this corresponds to horizontal scrolling.

x

.example {
  view-timeline: --reveal x;
}

Uses the physical horizontal axis regardless of writing mode.

y

.example {
  view-timeline: --reveal y;
}

Uses the physical vertical axis regardless of writing mode.

Logical vs. Physical Axes

The block and inline values follow the writing mode, while x and y refer to fixed physical directions.

Choosing an Axis

Use block for typical vertically scrolling pages and inline when the effect should follow the inline direction of the writing mode.

Important Consideration

A timeline requires a meaningful scrollable range along its selected axis. Choosing an axis that does not scroll can prevent the expected animation progress.

Multiple View Timelines

The view-timeline property can define more than one named timeline on the same element.

Two Timeline Definitions

.example {
  view-timeline: --vertical block, --horizontal inline;
}

Equivalent Longhand Declarations

.example {
  view-timeline-name: --vertical, --horizontal;
  view-timeline-axis: block, inline;
}

Using Different Timelines

.example {
  view-timeline: --vertical block, --horizontal inline;
}
.vertical-animation {
  animation-timeline: --vertical;
}
.horizontal-animation {
  animation-timeline: --horizontal;
}

Each animation can reference the timeline appropriate to its intended scrolling direction, provided the timeline is visible within the animation's lookup scope.

Comma-Separated Syntax

Each comma-separated definition represents a separate timeline name and its associated axis.

Important Consideration

Defining multiple timelines does not automatically create multiple animations. Each animation must be configured to use the appropriate timeline.

Using animation-timeline

The animation-timeline property connects a CSS animation to a view progress timeline.

Define the Timeline

.card {
  view-timeline: --card-reveal block;
}

Create Keyframes

@keyframes card-reveal {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

Attach the Animation

.card {
  animation-name: card-reveal;
  animation-duration: 1s;
  animation-timing-function: linear;
  animation-timeline: --card-reveal;
}

Animation Duration

For scroll-driven animations, the timeline determines progress rather than elapsed time. A positive duration such as 1s can be used for compatibility, but it does not make the animation take one second of scrolling.

Declaration Order

The animation shorthand resets animation-timeline. When using both, declare animation-timeline after the shorthand.

.card {
  animation: card-reveal 1s linear both;
  animation-timeline: --card-reveal;
}

Incorrect Declaration Order

.card {
  animation-timeline: --card-reveal;
  animation: card-reveal 1s linear both;
}

In this example, the later animation shorthand resets the timeline selection, preventing the intended named timeline from controlling the animation.

Important Consideration

A named timeline must be available to the animated element. If the name cannot be resolved, the animation will not follow the intended view progress timeline.

View Timeline Ranges

View progress timelines provide named ranges that describe different stages of an element moving through a scrollport.

cover

The cover range represents the subject's full passage through the scrollport, from entering one edge to leaving the opposite edge.

contain

The contain range represents the interval when the subject is fully contained within the scrollport, or when a larger subject fully covers the scrollport.

entry

The entry range represents the subject entering the scrollport.

exit

The exit range represents the subject leaving the scrollport.

entry-crossing

The entry-crossing range tracks the subject crossing the entry edge of the scrollport.

exit-crossing

The exit-crossing range tracks the subject crossing the exit edge of the scrollport.

Using animation-range

.card {
  view-timeline: --card-reveal block;
  animation: card-reveal 1s linear both;
  animation-timeline: --card-reveal;
  animation-range: entry 0% entry 100%;
}

The animation progresses across the subject's entry range instead of the entire view timeline.

Using cover

.card {
  animation-range: cover 0% cover 100%;
}

Using contain

.card {
  animation-range: contain 0% contain 100%;
}

Important Distinction

The view-timeline property defines the timeline name and axis. The animation-range property determines which portion of that timeline is used by the animation.

View Timeline vs. Scroll Timeline

CSS provides two related timeline types for scroll-driven animations.

View Progress Timeline

.card {
  view-timeline: --card-view block;
}

A view progress timeline tracks an element's position and visibility relative to a scrollport.

Scroll Progress Timeline

.scroll-container {
  scroll-timeline: --page-scroll block;
}

A scroll progress timeline tracks the scroll position of a scroll container across its available scrolling range.

Comparison

Feature view-timeline scroll-timeline
Tracks Subject progress through a scrollport Scroll container progress
Declared on The subject element The scroll container
Common use Content reveal animations Reading progress indicators
Axis values block, inline, x, y block, inline, x, y

Choosing the Correct Timeline

Use view-timeline when an animation should respond to a particular element entering or leaving the visible area. Use scroll-timeline when the animation should respond to the overall scroll progress of a container.

view-timeline-name

.example {
  view-timeline-name: --reveal;
}

Defines one or more names for view progress timelines.

view-timeline-axis

.example {
  view-timeline-axis: block;
}

Defines the axis used to measure view progress.

view-timeline-inset

.example {
  view-timeline-inset: 20px;
}

Adjusts the effective scrollport boundaries used to calculate view progress.

animation-timeline

.example {
  animation-timeline: --reveal;
}

Associates an animation with a named timeline.

animation-range

.example {
  animation-range: entry 0% entry 100%;
}

Defines the portion of an animation timeline over which the animation runs.

scroll-timeline

.scroll-container {
  scroll-timeline: --scroll-progress block;
}

Creates a named scroll progress timeline based on the scroll position of a container.

timeline-scope

.container {
  timeline-scope: --reveal;
}

Can extend the scope in which a named timeline is available, allowing certain elements outside the timeline subject's normal lookup relationship to reference it.

Complete Example

.card {
  view-timeline-name: --card-reveal;
  view-timeline-axis: block;
  view-timeline-inset: 10%;
  animation: fade-in 1s linear both;
  animation-timeline: --card-reveal;
  animation-range: entry 0% entry 100%;
}

Inheritance

The view-timeline property is not inherited. Child elements do not automatically declare the same view timeline as their parent.

Parent Timeline

.parent {
  view-timeline: --parent-view;
}

Child Animation

.parent .child {
  animation-name: fade-in;
  animation-duration: 1s;
  animation-timeline: --parent-view;
}

The child can reference the parent's named timeline without inheriting the view-timeline property.

Explicit Inheritance

.parent {
  view-timeline: --parent-view;
}
.parent .child {
  view-timeline: inherit;
}

The child explicitly inherits the computed shorthand values, creating its own timeline declaration using the inherited name and axis.

Restore the Initial Value

.example {
  view-timeline: initial;
}

This resets the timeline name to none and the axis to block.

Using unset

.example {
  view-timeline: unset;
}

Because the property is not inherited, unset restores the initial values.

Important Consideration

Timeline inheritance and timeline name lookup are different concepts. An animation can reference an eligible named timeline without inheriting its declaration.

Practical Examples

Reveal a Card During Scrolling

.card {
  view-timeline: --card-view block;
  animation: reveal-card 1s linear both;
  animation-timeline: --card-view;
  animation-range: entry 0% entry 100%;
}
@keyframes reveal-card {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

Fade In an Image

.reveal-image {
  view-timeline: --image-view block;
  animation: image-fade 1s linear both;
  animation-timeline: --image-view;
  animation-range: entry 0% entry 100%;
}
@keyframes image-fade {
  from {
    opacity: 0.3;
  }
  to {
    opacity: 1;
  }
}

Scale a Graphic

.scale-graphic {
  view-timeline: --graphic-view block;
  animation: graphic-scale 1s linear both;
  animation-timeline: --graphic-view;
  animation-range: entry 0% entry 100%;
}
@keyframes graphic-scale {
  from {
    transform: scale(0.8);
  }
  to {
    transform: scale(1);
  }
}

Horizontal Scroll Animation

.horizontal-card {
  view-timeline: --horizontal-view inline;
  animation: horizontal-reveal 1s linear both;
  animation-timeline: --horizontal-view;
  animation-range: entry 0% entry 100%;
}
@keyframes horizontal-reveal {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

Animate Child Content

.section {
  view-timeline: --section-view block;
}
.section-content {
  animation: content-reveal 1s linear both;
  animation-timeline: --section-view;
  animation-range: entry 0% entry 100%;
}
@keyframes content-reveal {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

Adjust the Viewport Inset

.card {
  view-timeline: --card-view block;
  view-timeline-inset: 15%;
}

The inset adjusts the effective visibility boundaries used to calculate the timeline's progress.

view-timeline Example

This example creates a scrollable container with a card that fades in and moves upward as it enters the visible area.

Scroll inside the demonstration to observe the animation. In browsers without the required scroll-driven animation support, the card remains visible without the effect.

HTML Example

<div class="view-demo">
  <div class="view-spacer">Scroll down to reveal the card</div>
  <div class="view-card">
    <h3>View Timeline Animation</h3>
    <p>This card animates as it enters the scrollport.</p>
  </div>
  <div class="view-spacer">Continue scrolling</div>
</div>

CSS Example

.view-demo {
  height: 300px;
  overflow-y: auto;
  padding: 15px;
  border: 1px solid #ccc;
}
.view-spacer {
  display: grid;
  place-items: center;
  height: 220px;
  color: #555;
}
.view-card {
  padding: 25px;
  background-color: #e5eef7;
  border: 2px solid #0066cc;
  border-radius: 6px;
}
.view-card h3 {
  margin: 0 0 10px;
}
.view-card p {
  margin: 0;
}
@keyframes view-reveal {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@supports (animation-timeline: view()) {
  .view-card {
    view-timeline: --card-view block;
    animation: view-reveal 1s linear both;
    animation-timeline: --card-view;
    animation-range: entry 0% entry 100%;
  }
}
@media (prefers-reduced-motion: reduce) {
  .view-card {
    animation: none;
  }
}
Browser Result
Scroll down to reveal the card

View Timeline Animation

This card animates as it enters the scrollport.

Continue scrolling

Understanding the Results

The scroll container has a fixed height and allows vertical scrolling. The card defines a named view timeline using view-timeline: --card-view block.

Timeline Progress

As the card enters the visible area, its view timeline advances through the entry range.

Animation Progress

The animation-timeline property connects the animation to the named timeline. The animation-range declaration limits the animation to the card's entry interval.

Opacity

The card begins transparent and becomes fully opaque as the entry animation progresses.

Vertical Movement

The card begins with a downward translation and moves toward its normal position.

Experiment With the Animation

Change the starting translation to increase the movement distance.

@keyframes view-reveal {
  from {
    opacity: 0;
    transform: translateY(80px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

Experiment With the Range

.view-card {
  animation-range: cover 0% cover 100%;
}

The animation now progresses across the card's full passage through the scrollport instead of only its entry interval.

Accessibility Considerations

Scroll-driven animations can improve visual presentation, but they should not prevent users from accessing important content.

Respect Reduced Motion Preferences

Some users prefer reduced motion because movement and animated transitions can cause discomfort.

@media (prefers-reduced-motion: reduce) {
  .animated-card {
    animation: none;
  }
}

Keep Essential Content Available

Important information should remain accessible even when scroll-driven animations are unsupported or disabled.

Avoid Scroll-Dependent Instructions

Do not require users to scroll through a specific animation sequence to understand essential instructions or complete a task.

Maintain Readable Contrast

Animations that change opacity should not make essential text difficult to read during normal interaction.

Avoid Excessive Movement

Large translations, repeated scaling, and rapid visual changes can be distracting.

Preserve Document Structure

Use semantic HTML headings, paragraphs, and sections. Visual animation does not replace meaningful document structure.

Support Keyboard Navigation

Interactive elements must remain reachable and usable by keyboard, regardless of animation progress.

Test Without Animation

Verify that the page remains understandable and usable when animations are disabled.

Common Mistakes

Using a Timeline Name Without Two Hyphens

.example {
  view-timeline: reveal;
}

Named timelines use dashed identifiers such as --reveal.

Defining a Timeline Without an Animation

.example {
  view-timeline: --reveal;
}

This creates a timeline but does not produce a visible animation by itself.

Forgetting animation-timeline

.example {
  view-timeline: --reveal;
  animation: fade-in 1s linear;
}

The animation is not connected to the named view timeline.

Using the Wrong Timeline Name

.example {
  view-timeline: --card-view;
  animation-timeline: --image-view;
}

The names must resolve to the intended timeline.

Using an Invalid Axis

.example {
  view-timeline: --reveal vertical;
}

Use block, inline, x, or y.

Assuming view-timeline Controls Scroll Position

The property tracks view progress. It does not scroll the page or change the scroll position.

Confusing View and Scroll Timelines

A view timeline tracks a subject moving through a scrollport. A scroll timeline tracks a scroll container's scroll progress.

Using an Unavailable Timeline Name

Timeline names must be accessible within the animated element's timeline lookup scope.

Resetting animation-timeline Accidentally

The animation shorthand resets animation-timeline. Declare the timeline after the shorthand.

Ignoring Browser Compatibility

Scroll-driven animation support is newer than traditional CSS animation support. Provide a usable fallback.

Ignoring Reduced Motion Preferences

Provide a reduced-motion alternative for animations that involve substantial movement.

Important Considerations

Keep the following points in mind when using view-timeline:

  • The property creates named view progress timelines.
  • It is part of CSS scroll-driven animations.
  • It is a shorthand for view-timeline-name and view-timeline-axis.
  • Its initial timeline name is none.
  • Its initial axis is block.
  • The property is not inherited.
  • Timeline names must begin with two hyphens.
  • The block axis follows the block direction of the writing mode.
  • The inline axis follows the inline direction.
  • The x axis represents physical horizontal scrolling.
  • The y axis represents physical vertical scrolling.
  • Multiple timelines can be defined with comma-separated values.
  • The timeline tracks a subject relative to its scrollport.
  • Timeline progress depends on scrolling rather than elapsed time.
  • Defining a timeline does not automatically create an animation.
  • The animation-timeline property attaches an animation to a timeline.
  • Named timelines follow timeline lookup scope rules.
  • The timeline-scope property can extend named timeline availability.
  • The animation-range property selects a portion of the timeline.
  • The view-timeline-inset property adjusts effective visibility boundaries.
  • The view-timeline-inset property is not part of the shorthand.
  • The animation shorthand resets animation-timeline.
  • Declare animation-timeline after the animation shorthand.
  • Use view-timeline for element visibility-based animation progress.
  • Use scroll-timeline for scroll container progress.
  • Choose an axis that corresponds to the intended scrolling direction.
  • Provide a usable fallback for browsers without support.
  • Respect reduced-motion preferences.
  • Keep important content available without animation.
  • Test scroll-driven effects across browsers and screen sizes.

Browser Support

The CSS view-timeline property has limited availability compared with established CSS layout and animation properties.

Support varies among browsers and versions. The property is implemented in Chromium-based browsers, while compatibility in other browser engines and older versions requires verification.

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

Standard Declaration

.example {
  view-timeline: --reveal block;
}

Feature Detection

@supports (animation-timeline: view()) and (view-timeline-name: --reveal) {
  .example {
    view-timeline: --reveal block;
    animation-timeline: --reveal;
  }
}

Progressive Enhancement

Start with visible, usable content and add scroll-driven animations only when the necessary features are supported.

.card {
  opacity: 1;
  transform: none;
}
@supports (animation-timeline: view()) and (view-timeline-name: --reveal) {
  .card {
    view-timeline: --reveal block;
    animation: card-reveal 1s linear both;
    animation-timeline: --reveal;
    animation-range: entry 0% entry 100%;
  }
}

Important Limitation

The @supports rule checks whether a browser recognizes the specified declarations. It does not guarantee that every scroll-driven animation behavior is implemented identically.

Testing Recommendations

Test the animation in supported browsers, verify its timeline lookup scope, and confirm that the content remains usable when scroll-driven animations are unavailable.

Specifications

The view-timeline property is defined in the Scroll-driven Animations Module Level 1 specification.

Scroll-driven Animations Module Level 1 - view-timeline Shorthand

The specification defines named view progress timelines, their axes, and how they interact with scroll-driven animations.

For additional documentation and examples, consult MDN Web Docs.

MDN Web Docs: view-timeline