CSS view-timeline-name Property
The CSS view-timeline-name property defines one or more named view progress timelines that track an element's visibility within a scroll container.
A named view progress timeline allows CSS animations to respond to the position of an element as it enters, moves through, or leaves the scrollport of its nearest ancestor scroll container. Other elements can reference the timeline through the animation-timeline property when the timeline is available within their timeline lookup scope.
The property is a longhand component of the view-timeline shorthand. It works with view-timeline-axis to select the scrolling axis and view-timeline-inset to adjust the effective visibility boundaries.
view-timeline-name Syntax
The view-timeline-name property accepts the keyword none or a comma-separated list of custom identifiers.
Basic Syntax
.example {
view-timeline-name: --reveal;
}
Default Value
.example {
view-timeline-name: none;
}
Multiple Timeline Names
.example {
view-timeline-name: --first-view, --second-view;
}
With a Timeline Axis
.example {
view-timeline-name: --card-view;
view-timeline-axis: block;
}
Equivalent Shorthand
.example {
view-timeline: --card-view block;
}
CSS-Wide Keywords
.example {
view-timeline-name: initial;
}
.example {
view-timeline-name: inherit;
}
.example {
view-timeline-name: unset;
}
.example {
view-timeline-name: revert;
}
.example {
view-timeline-name: revert-layer;
}
Invalid Values
.example {
view-timeline-name: reveal;
}
.example {
view-timeline-name: "reveal";
}
.example {
view-timeline-name: --first, none;
}
Named view timelines use dashed identifiers beginning with two hyphens. Quoted strings and ordinary identifiers are not valid timeline names. The keyword none must appear alone rather than as part of a comma-separated list.
Property Values
| Value | Description |
|---|---|
none |
Declares no named view progress timelines. This is the initial value. |
<dashed-ident> |
Defines a named view progress timeline using a custom identifier beginning with two hyphens. |
<dashed-ident>, <dashed-ident> |
Defines multiple named view progress timelines on the same element. |
Property Characteristics
| Characteristic | Value |
|---|---|
| Initial value | none |
| 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: Defining a timeline name does not automatically animate an element. An animation must reference the timeline using animation-timeline.
How It Works
A named view progress timeline uses an element as its subject and measures that element's position relative to the scrollport of its nearest ancestor scroll container.
As the subject enters and leaves the effective scrollport, the timeline provides progress values that can control CSS animations.
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: Name the Timeline
.card {
view-timeline-name: --card-view;
}
The card becomes the subject of the named view progress timeline.
Step 4: Select the Axis
.card {
view-timeline-axis: block;
}
The timeline measures progress along the block axis, which is vertical in a typical horizontal writing mode.
Step 5: Create Keyframes
@keyframes reveal {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
Step 6: Connect the Animation
.card {
animation: reveal 1s linear both;
animation-timeline: --card-view;
animation-range: entry 0% entry 100%;
}
The animation progresses as the card enters the effective scrollport.
Important Distinction
The timeline name identifies a source of animation progress. The animation's keyframes determine which visual properties change.
The none Value
The none value specifies that the element does not define any named view progress timelines through this property.
Syntax
.example {
view-timeline-name: none;
}
Default Behavior
The none value is the initial value, so elements do not create named view progress timelines unless a name is declared.
Removing a Named Timeline
.card {
view-timeline-name: --card-view;
}
.card.no-timeline {
view-timeline-name: none;
}
The second rule removes the named timeline declaration from elements with the no-timeline class.
Effect on Animations
If an animation references a name that no longer resolves to an available timeline, that animation cannot use the removed timeline to determine its progress.
When to Use It
Use none to reset named timeline declarations or disable timeline creation on selected elements.
Important Consideration
The none value does not disable every scroll-driven animation on the element. Other timelines, including anonymous timelines created with view(), may still be used.
Custom Timeline Identifiers
Named view progress timelines use custom identifiers called dashed identifiers. Their names begin with two hyphens.
Valid Names
.card {
view-timeline-name: --card-reveal;
}
.image {
view-timeline-name: --image-progress;
}
.section {
view-timeline-name: --section-view;
}
Invalid Names
.card {
view-timeline-name: card-reveal;
}
.image {
view-timeline-name: "image-progress";
}
Names without the required leading hyphens and quoted strings are invalid.
Referencing a Name
.card {
view-timeline-name: --card-reveal;
animation: reveal 1s linear both;
animation-timeline: --card-reveal;
}
The identifier used by animation-timeline must match the intended named timeline.
Names Are Case-Sensitive
.card {
view-timeline-name: --CardView;
animation-timeline: --cardview;
}
These identifiers are different because custom identifiers are case-sensitive.
Naming Recommendations
Choose descriptive names that identify the subject or intended effect, such as --image-reveal or --section-progress.
Important Consideration
Timeline names are identifiers, not CSS custom properties. They do not require a corresponding declaration such as --card-view: ....
Multiple Named Timelines
An element can define multiple named view progress timelines using a comma-separated list.
Two Timeline Names
.card {
view-timeline-name: --first-view, --second-view;
}
Different Axes
.card {
view-timeline-name: --block-view, --inline-view;
view-timeline-axis: block, inline;
}
The first timeline uses the block axis, while the second uses the inline axis.
Equivalent Shorthand
.card {
view-timeline: --block-view block, --inline-view inline;
}
One Axis for Multiple Names
.card {
view-timeline-name: --first-view, --second-view;
view-timeline-axis: block;
}
When the axis list is shorter than the name list, its values repeat. Both timelines use the block axis.
Referencing Different Timelines
.card {
view-timeline-name: --card-block, --card-inline;
view-timeline-axis: block, inline;
}
.card-content {
animation: reveal 1s linear both;
animation-timeline: --card-block;
}
The child animation references the block-axis timeline.
Important Consideration
Multiple timeline names do not automatically create multiple animations. Each animation must be associated with its intended timeline.
Choosing the Timeline Axis
The view-timeline-axis property determines which scrolling axis a named view progress timeline uses.
Block Axis
.card {
view-timeline-name: --card-view;
view-timeline-axis: block;
}
The block value is the default. In horizontal writing modes, it generally corresponds to vertical scrolling.
Inline Axis
.gallery-item {
view-timeline-name: --gallery-view;
view-timeline-axis: inline;
}
In horizontal writing modes, the inline axis generally corresponds to horizontal scrolling.
Physical Horizontal Axis
.gallery-item {
view-timeline-name: --gallery-view;
view-timeline-axis: x;
}
Physical Vertical Axis
.card {
view-timeline-name: --card-view;
view-timeline-axis: y;
}
Logical vs. Physical Axes
The block and inline values adapt to the scroll container's writing mode. The x and y values always represent physical horizontal and vertical directions.
Important Consideration
Choose an axis that corresponds to meaningful scrolling in the nearest ancestor scroll container. A timeline may not provide the expected progress if the selected axis has no usable scroll range.
Adjusting Timeline Insets
The view-timeline-inset property adjusts the effective scrollport boundaries used to calculate view progress.
Default Insets
.card {
view-timeline-name: --card-view;
view-timeline-inset: auto;
}
The auto value uses the relevant automatic inset, taking scroll-padding into account.
Fixed Insets
.card {
view-timeline-name: --card-view;
view-timeline-inset: 40px;
}
Percentage Insets
.card {
view-timeline-name: --card-view;
view-timeline-inset: 10%;
}
Different Start and End Insets
.card {
view-timeline-name: --card-view;
view-timeline-inset: 20% 5%;
}
Negative Insets
.card {
view-timeline-name: --card-view;
view-timeline-inset: -20px;
}
Negative values extend the effective timeline boundaries beyond the normal scrollport.
Important Consideration
Insets affect timeline calculations but do not change the scroll container's actual dimensions or clipping area.
Connecting an Animation
The animation-timeline property associates a CSS animation with a named view progress timeline.
Define the Timeline
.card {
view-timeline-name: --card-reveal;
view-timeline-axis: block;
}
Create Keyframes
@keyframes card-reveal {
from {
opacity: 0;
transform: translateY(30px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
Attach the Animation
.card {
animation: card-reveal 1s linear both;
animation-timeline: --card-reveal;
animation-range: entry 0% entry 100%;
}
Understanding the Animation Range
The entry range represents the subject entering the effective scrollport. The animation progresses across that range rather than using elapsed time.
Animate a Child Element
.section {
view-timeline-name: --section-view;
}
.section-content {
animation: fade-in 1s linear both;
animation-timeline: --section-view;
animation-range: entry 0% entry 100%;
}
The section defines the timeline, while its child references the timeline to control its animation.
Declaration Order
The animation shorthand resets animation-timeline. Declare animation-timeline after the shorthand.
Important Consideration
The animation must be able to resolve the timeline name within the applicable timeline lookup scope.
Timeline Scope and Lookup
Named view progress timelines follow timeline lookup rules that determine which animations can reference them.
Timeline on the Animated Element
.card {
view-timeline-name: --card-view;
animation: reveal 1s linear both;
animation-timeline: --card-view;
}
The element can reference its own named timeline.
Timeline on an Ancestor
.section {
view-timeline-name: --section-view;
}
.section .content {
animation: reveal 1s linear both;
animation-timeline: --section-view;
}
The descendant can reference the ancestor's named timeline when it is available through timeline lookup.
Timeline on a Sibling
A named timeline defined on one sibling is not automatically available to an animation on another sibling.
Using timeline-scope
.container {
timeline-scope: --image-view;
}
.image {
view-timeline-name: --image-view;
}
.caption {
animation: reveal 1s linear both;
animation-timeline: --image-view;
}
The timeline-scope property can extend the availability of a named timeline so that an eligible sibling animation can reference it.
Duplicate Names
When multiple timelines use the same name, timeline lookup rules determine which timeline is selected. Avoid unnecessary duplicate names when the intended relationship could become unclear.
Important Consideration
Timeline names are not automatically global identifiers. Their availability depends on the document structure and timeline lookup rules.
The view-timeline Shorthand
The view-timeline shorthand combines view-timeline-name and view-timeline-axis into a single declaration.
Longhand Declarations
.card {
view-timeline-name: --card-view;
view-timeline-axis: block;
}
Equivalent Shorthand
.card {
view-timeline: --card-view block;
}
Omitting the Default Axis
.card {
view-timeline: --card-view;
}
The block axis is used by default.
Multiple Timelines
.card {
view-timeline: --block-view block, --inline-view inline;
}
Separate Insets
.card {
view-timeline: --card-view block;
view-timeline-inset: 10%;
}
The view-timeline-inset property is separate from the shorthand and must be declared independently.
Shorthand Reset Behavior
.card {
view-timeline-axis: inline;
view-timeline: --card-view;
}
The shorthand resets the axis to its default block value because no axis is specified in the shorthand declaration.
Important Consideration
When mixing shorthand and longhand declarations, pay attention to declaration order because the shorthand resets its component properties.
Related CSS Properties
view-timeline
.card {
view-timeline: --card-view block;
}
Defines the timeline name and scrolling axis using a shorthand declaration.
view-timeline-axis
.card {
view-timeline-axis: block;
}
Specifies the axis used to calculate view progress.
view-timeline-inset
.card {
view-timeline-inset: 10%;
}
Adjusts the effective scrollport boundaries used for timeline calculations.
animation-timeline
.card {
animation-timeline: --card-view;
}
Associates an animation with a named timeline.
animation-range
.card {
animation-range: entry 0% entry 100%;
}
Defines the portion of the timeline used by an animation.
scroll-timeline-name
.scroll-container {
scroll-timeline-name: --scroll-progress;
}
Creates a named scroll progress timeline based on a scroll container's scroll position rather than an element's visibility.
timeline-scope
.container {
timeline-scope: --card-view;
}
Controls the scope in which a named timeline can be referenced.
Complete Example
.card {
view-timeline-name: --card-view;
view-timeline-axis: block;
view-timeline-inset: 10%;
animation: reveal 1s linear both;
animation-timeline: --card-view;
animation-range: entry 0% entry 100%;
}
Inheritance
The view-timeline-name property is not inherited. Child elements do not automatically receive the timeline names declared on their parents.
Parent Declaration
.parent {
view-timeline-name: --parent-view;
}
Child Declaration
.parent .child {
view-timeline-name: --child-view;
}
The child defines its own named timeline.
Explicit Inheritance
.parent {
view-timeline-name: --parent-view;
}
.parent .child {
view-timeline-name: inherit;
}
The child inherits the parent's computed timeline name, creating a separate timeline declaration on the child using that identifier.
Restore the Initial Value
.example {
view-timeline-name: initial;
}
This restores the initial value of none.
Using unset
.example {
view-timeline-name: unset;
}
Because the property is not inherited, unset behaves like initial.
Important Distinction
A child element can reference an ancestor's named timeline through animation-timeline without inheriting the view-timeline-name property.
Practical Examples
Vertical Content Reveal
.reveal-card {
view-timeline-name: --card-reveal;
view-timeline-axis: block;
animation: fade-in 1s linear both;
animation-timeline: --card-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%;
}
Animate a Section Heading
.content-section {
view-timeline-name: --section-view;
}
.content-section h2 {
animation: heading-reveal 1s linear both;
animation-timeline: --section-view;
animation-range: entry 0% entry 100%;
}
Animate an Image Caption
.image-wrapper {
view-timeline-name: --image-view;
}
.image-caption {
animation: caption-reveal 1s linear both;
animation-timeline: --image-view;
animation-range: entry 0% entry 100%;
}
Multiple Named Timelines
.card {
view-timeline-name: --vertical-view, --horizontal-view;
view-timeline-axis: block, inline;
}
Responsive Timeline Insets
.card {
view-timeline-name: --card-view;
view-timeline-inset: 15%;
}
Using the Shorthand
.card {
view-timeline: --card-view block;
}
Disable a Named Timeline
.card.no-animation {
view-timeline-name: none;
}
This removes the named timeline declaration from the selected card.
view-timeline-name Example
This example demonstrates how view-timeline-name creates a named timeline that controls a card's animation as it enters a scroll container.
Scroll down inside the demonstration to see the card fade in and move into position. The card remains visible without the effect in browsers that do not support the required scroll-driven animation features.
HTML Example
<div class="timeline-demo">
<div class="timeline-scroll">
<div class="timeline-spacer">Scroll down to reveal the card</div>
<div class="timeline-card">
<h3>Named View Timeline</h3>
<p>This card animates as it enters the scrollport.</p>
</div>
<div class="timeline-spacer">Continue scrolling</div>
</div>
</div>
CSS Example
.timeline-scroll {
height: 250px;
overflow-y: auto;
padding: 10px;
border: 1px solid #ccc;
}
.timeline-spacer {
display: grid;
place-items: center;
height: 220px;
color: #555;
text-align: center;
}
.timeline-card {
padding: 25px;
background-color: #e5eef7;
border: 2px solid #0066cc;
border-radius: 6px;
text-align: center;
}
.timeline-card h3 {
margin: 0 0 10px;
}
.timeline-card p {
margin: 0;
}
@keyframes timeline-reveal {
from {
opacity: 0;
transform: translateY(40px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@supports (view-timeline-name: --test) and (animation-timeline: view()) {
.timeline-card {
view-timeline-name: --card-reveal;
view-timeline-axis: block;
animation: timeline-reveal 1s linear both;
animation-timeline: --card-reveal;
animation-range: entry 0% entry 100%;
}
}
@media (prefers-reduced-motion: reduce) {
.timeline-card {
animation: none;
}
}
Named View Timeline
This card animates as it enters the scrollport.
Understanding the Results
The card creates a named view progress timeline using view-timeline-name: --card-reveal.
Timeline Axis
The view-timeline-axis: block declaration measures progress along the block axis, which is vertical in this demonstration.
Animation Connection
The animation-timeline: --card-reveal declaration connects the animation to the card's named timeline.
Entry Range
The animation-range: entry 0% entry 100% declaration causes the animation to progress as the card enters the effective scrollport.
Experiment With the Timeline Name
Change the timeline identifier in both declarations.
.timeline-card {
view-timeline-name: --custom-reveal;
animation-timeline: --custom-reveal;
}
The animation continues to work because the identifiers match.
Experiment With the Axis
.timeline-card {
view-timeline-axis: y;
}
For this vertically scrolling demonstration, the physical y axis produces the same measurement direction as the block axis.
Experiment With Insets
.timeline-card {
view-timeline-inset: 15%;
}
The effective visibility boundaries move inward, changing the scroll positions associated with the animation's entry range.
Accessibility Considerations
The view-timeline-name property identifies scroll-driven animation timelines. It does not change document semantics, reading order, or keyboard navigation.
Respect Reduced Motion Preferences
Provide an alternative for users who prefer reduced motion.
@media (prefers-reduced-motion: reduce) {
.animated-card {
animation: none;
}
}
Keep Essential Content Visible
Important information should remain available when animations are unsupported, disabled, or have not yet progressed.
Avoid Hidden Interactive Controls
Do not make buttons, links, or form controls depend on an animation reaching a particular progress value before they become discoverable.
Maintain Readable Text
Animations that change opacity, scale, or position should not make important text difficult to read.
Avoid Excessive Motion
Large translations and repeated scaling effects can be distracting or uncomfortable.
Support Keyboard Scrolling
Scrollable regions should remain accessible to keyboard users when interaction with them is necessary.
Test Without Animation
Verify that the page remains understandable and usable when scroll-driven animations are unavailable.
Common Mistakes
Omitting the Required Hyphens
.card {
view-timeline-name: card-reveal;
}
Timeline names must use dashed identifiers such as --card-reveal.
Using a Quoted String
.card {
view-timeline-name: "--card-reveal";
}
Timeline names are identifiers, not strings.
Combining none With a Name
.card {
view-timeline-name: none, --card-reveal;
}
The none keyword cannot be combined with named timelines in the same value list.
Using Different Timeline Names
.card {
view-timeline-name: --card-view;
animation-timeline: --card-reveal;
}
The animation references a different name and cannot use the intended timeline unless that name resolves to another available timeline.
Assuming Names Are Global
Named timelines follow timeline lookup rules. A timeline is not automatically available to every element in the document.
Confusing Timeline Names With CSS Variables
Timeline names use dashed identifiers but are not CSS custom property declarations.
Forgetting animation-timeline
Defining a named timeline does not automatically attach an animation to it.
Choosing the Wrong Axis
A timeline may not provide the expected progress when its axis does not correspond to meaningful scrolling.
Resetting animation-timeline
The animation shorthand resets animation-timeline. Declare the timeline after the shorthand.
Ignoring Browser Support
Provide fallbacks because support for scroll-driven animations varies among browsers.
Ignoring Reduced Motion Preferences
Disable or simplify substantial motion when the user requests reduced motion.
Important Considerations
Keep the following points in mind when using view-timeline-name:
- The property defines named view progress timelines.
- It is part of CSS scroll-driven animations.
- Its initial value is
none. - The property is not inherited.
- It is a longhand component of
view-timeline. - Named timelines use dashed identifiers beginning with two hyphens.
- Timeline names are case-sensitive.
- Timeline names are not CSS custom property declarations.
- The
nonevalue declares no named view progress timelines. - The
nonekeyword cannot be mixed with names in a value list. - Multiple timeline names can be separated by commas.
- Each timeline name can be associated with an axis.
- The default timeline axis is
block. - Logical axes depend on the scroll container's writing mode.
- Physical axes use fixed horizontal or vertical directions.
- The nearest ancestor scroll container provides the view progress reference.
- The element declaring the name is the timeline's subject.
- Timeline progress depends on the subject's position within the effective scrollport.
- Use
view-timeline-axisto select the scrolling axis. - Use
view-timeline-insetto adjust effective visibility boundaries. - Use
animation-timelineto connect an animation to a named timeline. - Use
animation-rangeto select the portion of the timeline used by an animation. - Timeline names follow timeline lookup scope rules.
- Descendant animations can reference eligible ancestor timelines.
- Sibling timelines may require
timeline-scopeto make them available. - Duplicate timeline names can make timeline lookup harder to understand.
- The
view-timelineshorthand resets its name and axis components. - The
view-timeline-insetproperty is not part of the shorthand. - The
animationshorthand resetsanimation-timeline. - Declare
animation-timelineafter the animation shorthand. - Provide fallbacks for unsupported browsers.
- Respect reduced-motion preferences.
- Keep essential content accessible without animation.
- Test timeline behavior across different scroll containers and screen sizes.
Browser Support
The CSS view-timeline-name 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 should be checked before relying on it.
For current compatibility information, visit Can I Use? and search for view-timeline-name.
Standard Declaration
.card {
view-timeline-name: --card-view;
view-timeline-axis: block;
}
Feature Detection
@supports (view-timeline-name: --test) and (animation-timeline: view()) {
.card {
view-timeline-name: --card-view;
animation-timeline: --card-view;
}
}
Progressive Enhancement
Start with visible content and add scroll-driven animations when the required features are supported.
.card {
opacity: 1;
transform: none;
}
@supports (view-timeline-name: --test) and (animation-timeline: view()) {
.card {
view-timeline-name: --card-view;
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-name name. Experimental implementations may differ, so consult current browser documentation when targeting older versions.
Testing Recommendations
Test named timeline lookup, different scrolling axes, and animation ranges. Verify that content remains usable when scroll-driven animations are unsupported.
Specifications
The view-timeline-name property is defined in the Scroll-driven Animations Module Level 1 specification.
Scroll-driven Animations Module Level 1 - view-timeline-name
The specification defines how named view progress timelines are declared and used to track an element's position relative to a scrollport.
For additional documentation and examples, consult MDN Web Docs.
