CSS view-timeline-axis Property

The CSS view-timeline-axis property specifies the scrolling axis used to calculate progress for a named view progress timeline.

It determines whether an element's movement through a scrollport is measured along the block axis, inline axis, horizontal axis, or vertical axis. The property works with view-timeline-name and is a longhand component of the view-timeline shorthand.

View progress timelines allow CSS animations to respond to an element entering, moving through, or leaving the visible area of a scroll container.

view-timeline-axis Syntax

The view-timeline-axis property accepts a logical or physical axis keyword, or a comma-separated list of axis keywords.

Basic Syntax

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

Logical Axis Values

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

Physical Axis Values

.example {
  view-timeline-axis: x;
}
.example {
  view-timeline-axis: y;
}

Multiple Axis Values

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

Using a Named Timeline

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

Equivalent Shorthand

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

CSS-Wide Keywords

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

Invalid Values

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

The keywords vertical and horizontal are not valid values. Use y and x for physical vertical and horizontal axes.

Property Values

Value Description
block Measures progress along the scroll container's block axis. This is the initial value.
inline Measures progress along the scroll container's inline axis.
x Measures progress along the physical horizontal axis.
y Measures progress along the physical vertical axis.

Property Characteristics

Characteristic Value
Initial value block
Inherited No
Applies to All elements
Computed value As specified
Animation type Discrete
Percentages Not applicable
Shorthand view-timeline
Specification Scroll-driven Animations Module Level 1

Note: The property specifies the axis but does not create a named timeline on its own. Use view-timeline-name or the view-timeline shorthand to declare a timeline.

How It Works

A view progress timeline measures how a subject element moves through the visible area of its nearest ancestor scroll container along a selected axis.

The view-timeline-axis property selects that axis, while view-timeline-name gives the timeline an identifier that animations can reference.

Step 1: Create a Scroll Container

<div class="scroll-container">
  <div class="spacer"></div>
  <div class="card">Animated Card</div>
  <div class="spacer"></div>
</div>

Step 2: Enable Scrolling

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

Step 3: Define the Timeline

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

The card creates a named view progress timeline along the block axis.

Step 4: Create Keyframes

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

Step 5: Attach the Animation

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

The animation advances as the card enters the scrollport along the selected axis.

Important Distinction

The axis property does not control the direction of an animation's visual movement. It controls the scrolling direction used to calculate timeline progress.

The block Value

The block value measures view progress along the scroll container's block axis.

For common horizontal writing modes, the block axis is vertical.

Syntax

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

Named Timeline Example

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

Equivalent Shorthand

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

Default Behavior

Because block is the initial value, it can be omitted when using the shorthand.

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

How It Behaves

In a typical vertically scrolling page, progress changes as the subject enters and leaves the scrollport vertically.

When to Use It

Use block for scroll-driven content reveals, vertically scrolling articles, and effects that should follow the block direction of the writing mode.

The inline Value

The inline value measures view progress along the scroll container's inline axis.

For common horizontal writing modes, the inline axis is horizontal.

Syntax

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

Named Timeline Example

.horizontal-card {
  view-timeline-name: --horizontal-view;
  view-timeline-axis: inline;
}

Equivalent Shorthand

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

Horizontal Scroll Container

.horizontal-container {
  display: flex;
  gap: 20px;
  overflow-x: auto;
}
.horizontal-card {
  flex: 0 0 250px;
  view-timeline: --horizontal-view inline;
}

How It Behaves

As the card moves horizontally through the scrollport, its timeline progress changes.

When to Use It

Use inline for horizontal scrolling galleries, carousels, and layouts that should adapt to different writing modes.

The x and y Values

The x and y values specify physical axes that do not change with the writing mode.

The x Value

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

The x value measures progress along the horizontal axis.

The y Value

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

The y value measures progress along the vertical axis.

Horizontal Timeline

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

Vertical Timeline

.vertical-card {
  view-timeline: --vertical-view y;
}

Physical vs. Logical Axes

Unlike block and inline, physical axes do not adapt to the writing mode.

When to Use Them

Use x when an effect must follow horizontal scrolling and y when it must follow vertical scrolling, regardless of writing mode.

Writing Modes and Logical Axes

The logical axis values block and inline depend on the writing mode of the scroll container.

Horizontal Writing Mode

.container {
  writing-mode: horizontal-tb;
}

In this writing mode, the block axis is vertical and the inline axis is horizontal.

Vertical Writing Mode

.container {
  writing-mode: vertical-rl;
}

In this writing mode, the block axis is horizontal and the inline axis is vertical.

Logical Axis Example

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

The physical direction used by block depends on the scroll container's writing mode.

Physical Axis Example

.card {
  view-timeline-axis: y;
}

The y value always selects the physical vertical axis.

Comparison

Value horizontal-tb vertical-rl
block Vertical Horizontal
inline Horizontal Vertical
x Horizontal Horizontal
y Vertical Vertical

Important Consideration

Logical axes are useful for internationalized layouts because they adapt to the writing mode. Physical axes are useful when the effect must follow a fixed screen direction.

Multiple Timeline Axes

The view-timeline-axis property accepts a comma-separated list of values when an element defines multiple view progress timelines.

Two Timeline Axes

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

Equivalent Shorthand

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

Physical Axes

.example {
  view-timeline-name: --x-view, --y-view;
  view-timeline-axis: x, y;
}

How Lists Are Matched

Each timeline name is paired with an axis value. When the axis list is shorter than the name list, its values repeat to match the number of timeline names.

Repeated Axis Example

.example {
  view-timeline-name: --first, --second;
  view-timeline-axis: block;
}

Both named timelines use the block axis.

Important Consideration

Defining multiple timelines does not create multiple animations. Each animation must reference the appropriate timeline name.

Working With Named Timelines

The view-timeline-axis property works with view-timeline-name to define how a named timeline measures view progress.

Define the Name

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

Define the Axis

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

Combined Declaration

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

Equivalent Shorthand

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

Referencing the Timeline

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

Timeline Lookup

Named timelines are resolved according to timeline lookup rules. An animation can reference a timeline defined on itself or an eligible element within its timeline lookup scope.

Timeline Scope

The timeline-scope property can extend the availability of named timelines for more complex layouts.

Important Consideration

Declaring an axis without a timeline name does not create a named timeline that can be referenced by animation-timeline.

Connecting an Animation

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

Step 1: Define a Named Timeline

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

Step 2: Create Keyframes

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

Step 3: Attach the Animation

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

Animation Progress

The animation progresses as the subject enters the scrollport along the selected block axis.

Changing the Axis

.card {
  view-timeline-axis: inline;
}

The timeline now measures view progress along the inline axis instead.

Declaration Order

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

Important Consideration

The animation's keyframes determine what changes visually. The timeline axis determines which scrolling movement controls that animation.

view-timeline

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

Combines the timeline name and axis into one shorthand declaration.

view-timeline-name

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

Defines the name used to identify a view progress timeline.

view-timeline-inset

.example {
  view-timeline-inset: 10%;
}

Adjusts the effective scrollport boundaries used to calculate view progress.

animation-timeline

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

Associates a CSS animation with a named timeline.

animation-range

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

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

scroll-timeline-axis

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

Defines the axis used by a scroll progress timeline rather than a view progress timeline.

writing-mode

.container {
  writing-mode: vertical-rl;
}

Determines the logical block and inline directions used by layout and logical axis values.

timeline-scope

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

Controls the scope in which certain named timelines can be referenced.

Inheritance

The view-timeline-axis property is not inherited. Child elements do not automatically receive the axis value declared on their parent.

Parent Declaration

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

Child Declaration

.parent .child {
  view-timeline-axis: block;
}

The child uses its own declared value.

Explicit Inheritance

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

The child explicitly inherits the parent's computed axis value.

Restore the Initial Value

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

This restores the initial value of block.

Using unset

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

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

Important Consideration

Inheriting an axis value does not automatically inherit or create a timeline name. The timeline name and axis are separate properties.

Practical Examples

Vertical Content Reveal

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

Horizontal Gallery

.gallery-item {
  view-timeline-name: --gallery-view;
  view-timeline-axis: inline;
  animation: fade-in 1s linear both;
  animation-timeline: --gallery-view;
  animation-range: entry 0% entry 100%;
}

Physical Horizontal Axis

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

Physical Vertical Axis

.vertical-item {
  view-timeline: --vertical-view y;
}

Multiple Named Timelines

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

Animate a Child Element

.section {
  view-timeline-name: --section-view;
  view-timeline-axis: block;
}
.section-content {
  animation: fade-in 1s linear both;
  animation-timeline: --section-view;
  animation-range: entry 0% entry 100%;
}

Adjust Visibility Boundaries

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

The inset adjusts the effective visibility range while the axis determines the direction used to measure progress.

view-timeline-axis Example

This example demonstrates the block and inline axis values using separate vertical and horizontal scroll containers.

Scroll inside each container to see the cards animate as they enter the visible area. Unsupported browsers display the cards without scroll-driven effects.

HTML Example

<div class="axis-demo">
  <h3>Block Axis</h3>
  <div class="vertical-scroll">
    <div class="vertical-spacer">Scroll down</div>
    <div class="vertical-card">Block Axis Animation</div>
    <div class="vertical-spacer">Continue scrolling</div>
  </div>
  <h3>Inline Axis</h3>
  <div class="horizontal-scroll">
    <div class="horizontal-spacer">Scroll right</div>
    <div class="horizontal-card">Inline Axis Animation</div>
    <div class="horizontal-spacer">Continue scrolling</div>
  </div>
</div>

CSS Example

.axis-demo h3 {
  margin: 15px 0 10px;
}
.vertical-scroll {
  height: 220px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid #ccc;
}
.vertical-spacer {
  display: grid;
  place-items: center;
  height: 180px;
}
.vertical-card,
.horizontal-card {
  display: grid;
  place-items: center;
  padding: 20px;
  background-color: #e5eef7;
  border: 2px solid #0066cc;
  border-radius: 6px;
  text-align: center;
}
.horizontal-scroll {
  display: flex;
  gap: 15px;
  overflow-x: auto;
  padding: 10px;
  border: 1px solid #ccc;
}
.horizontal-spacer {
  display: grid;
  place-items: center;
  flex: 0 0 220px;
  min-height: 120px;
}
.horizontal-card {
  flex: 0 0 200px;
}
@keyframes axis-reveal {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
@supports (animation-timeline: view()) and (view-timeline-name: --test) {
  .vertical-card {
    view-timeline-name: --vertical-view;
    view-timeline-axis: block;
    animation: axis-reveal 1s linear both;
    animation-timeline: --vertical-view;
    animation-range: entry 0% entry 100%;
  }
  .horizontal-card {
    view-timeline-name: --horizontal-view;
    view-timeline-axis: inline;
    animation: axis-reveal 1s linear both;
    animation-timeline: --horizontal-view;
    animation-range: entry 0% entry 100%;
  }
}
@media (prefers-reduced-motion: reduce) {
  .vertical-card,
  .horizontal-card {
    animation: none;
  }
}
Browser Result

Block Axis

Scroll down
Block Axis Animation
Continue scrolling

Inline Axis

Scroll right
Inline Axis Animation
Continue scrolling

Understanding the Results

The demonstration contains two independent scroll containers, each with its own named view progress timeline.

Block Axis Animation

The first container scrolls vertically. The card uses view-timeline-axis: block, so its animation progresses as it enters the visible area along the block axis.

Inline Axis Animation

The second container scrolls horizontally. The card uses view-timeline-axis: inline, so its animation progresses as it enters along the inline axis.

Shared Keyframes

Both cards use the same opacity and scale animation. The difference is the axis that controls timeline progress.

Experiment With the Axis

Change the vertical card to use the physical vertical axis.

.vertical-card {
  view-timeline-axis: y;
}

In a horizontal writing mode, the result is equivalent to using block for vertical scrolling.

Experiment With the Horizontal Axis

.horizontal-card {
  view-timeline-axis: x;
}

In a horizontal writing mode, the result is equivalent to using inline for horizontal scrolling.

Accessibility Considerations

The view-timeline-axis property affects how scroll-driven animation progress is measured. It does not change document semantics or reading order.

Respect Reduced Motion Preferences

Provide alternatives for users who prefer reduced motion.

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

Keep Content Available

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

Avoid Essential Scroll-Dependent Actions

Do not require users to complete a precise scrolling movement to reveal essential controls or instructions.

Support Keyboard Scrolling

Scrollable regions should remain usable with a keyboard when interaction with them is necessary.

Avoid Excessive Motion

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

Preserve Readability

Ensure text remains readable throughout animations that change opacity or position.

Test Different Writing Modes

When supporting internationalized layouts, verify that logical axis values behave as intended.

Test Without Animation

Confirm that the page remains understandable and usable when animation effects are removed.

Common Mistakes

Using vertical Instead of y

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

The vertical keyword is invalid. Use y for the physical vertical axis.

Using horizontal Instead of x

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

The horizontal keyword is invalid. Use x for the physical horizontal axis.

Declaring an Axis Without a Timeline Name

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

This does not create a named timeline by itself.

Confusing Logical and Physical Axes

The block and inline values depend on writing mode. The x and y values use fixed physical axes.

Choosing the Wrong Scroll Axis

An axis that does not correspond to meaningful scrolling may prevent the expected timeline progress.

Forgetting animation-timeline

Defining a view timeline does not automatically attach an animation to it.

Using an Incorrect Timeline Name

The name referenced by animation-timeline must resolve to the intended timeline.

Confusing the Axis With Animation Direction

The axis controls how scrolling determines animation progress, not whether the animated element moves horizontally or vertically.

Resetting animation-timeline

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

Ignoring Browser Support

Provide a usable fallback because scroll-driven animation support varies across browsers.

Ignoring Reduced Motion Preferences

Disable or simplify substantial movement when the user requests reduced motion.

Important Considerations

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

  • The property selects the axis used by a named view progress timeline.
  • It is part of CSS scroll-driven animations.
  • Its initial value is block.
  • The property is not inherited.
  • It is a longhand component of view-timeline.
  • The block value uses the scroll container's block axis.
  • The inline value uses the scroll container's inline axis.
  • The x value uses the physical horizontal axis.
  • The y value uses the physical vertical axis.
  • Logical axes depend on writing mode.
  • Physical axes do not change with writing mode.
  • Multiple axis values can be separated by commas.
  • Axis values are paired with named view timelines.
  • A shorter axis list repeats to match the timeline name list.
  • Declaring an axis alone does not create a named timeline.
  • Use view-timeline-name to define a timeline identifier.
  • Use animation-timeline to connect an animation to a timeline.
  • Timeline names follow timeline lookup scope rules.
  • The axis determines scroll progress measurement, not visual animation direction.
  • The selected axis should correspond to meaningful scrolling.
  • The animation-range property controls which part of the timeline is used.
  • The view-timeline-inset property adjusts effective visibility boundaries.
  • The animation shorthand resets animation-timeline.
  • Declare animation-timeline after the animation shorthand.
  • Use logical axes for layouts that should adapt to writing modes.
  • Use physical axes for effects tied to fixed directions.
  • Provide fallbacks for browsers without support.
  • Respect reduced-motion preferences.
  • Keep important content accessible without animation.
  • Test scrolling behavior across screen sizes and writing modes.

Browser Support

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

Support varies among browsers and versions. The property is implemented in Chromium-based browsers, while compatibility in other browser engines and older versions should be checked before relying on it.

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

Standard Declaration

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

Feature Detection

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

Progressive Enhancement

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

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

Vendor Prefixes

The standard property uses the unprefixed view-timeline-axis name. Experimental implementations may differ, so check current browser documentation when targeting older versions.

Testing Recommendations

Test both logical and physical axes, confirm the selected scroll direction, and verify that content remains usable when the feature is unsupported.

Specifications

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

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

The specification describes the supported axis values and their role in calculating view progress timelines.

For additional documentation and examples, consult MDN Web Docs.

MDN Web Docs: view-timeline-axis