CSS timeline-scope Property
The CSS timeline-scope property expands the scope of named animation timelines so that elements in different descendant branches can reference the same timeline.
It is used with scroll-driven animations, particularly named scroll progress timelines created using scroll-timeline-name and view progress timelines created using view-timeline-name. By declaring a timeline name on a shared ancestor, animations can reference a timeline defined elsewhere within that ancestor's subtree.
timeline-scope Syntax
The property accepts none or a comma-separated list of custom timeline names.
Basic Syntax
.container {
timeline-scope: --page-scroll;
}
Available Values
.container {
timeline-scope: none;
}
.container {
timeline-scope: --page-scroll;
}
.container {
timeline-scope: --page-scroll, --section-view;
}
CSS-Wide Keywords
.container {
timeline-scope: initial;
}
.container {
timeline-scope: inherit;
}
.container {
timeline-scope: unset;
}
.container {
timeline-scope: revert;
}
.container {
timeline-scope: revert-layer;
}
Invalid Examples
.container {
timeline-scope: auto;
}
.container {
timeline-scope: all;
}
.container {
timeline-scope: --first --second;
}
.container {
timeline-scope: none, --page-scroll;
}
.container {
timeline-scope: 300px;
}
The none keyword must appear alone. Multiple timeline names must be separated by commas, and length values are not accepted.
Property Values
| Value | Description |
|---|---|
none |
Does not establish an expanded scope for any named timeline. |
<dashed-ident> |
Specifies a named timeline whose scope should be expanded to the declaring element's subtree. |
| Comma-separated names | Expands the scope of multiple named timelines. |
initial |
Restores the initial value, none. |
inherit |
Uses the computed value of the parent element. |
unset |
Restores the initial value because the property is not inherited. |
revert |
Reverts the value according to the CSS cascade. |
revert-layer |
Reverts the value according to the previous cascade layer. |
Property Characteristics
| Characteristic | Value |
|---|---|
| Initial value | none |
| Inherited | No |
| Applies to | All elements |
| Computed value | As specified |
| Animation type | Discrete |
| Percentages | Not accepted |
| Specification | Scroll-driven Animations Level 1 |
Note: The property does not create a scroll or view timeline. It changes where an existing named timeline can be referenced.
How It Works
Named animation timelines normally have a limited scope. The timeline-scope property allows a common ancestor to extend that scope across different branches of its descendant tree.
Step 1: Create a Shared Container
<div class="layout">
<div class="scroll-area">Scrollable content</div>
<div class="progress-indicator"></div>
</div>
Step 2: Name the Scroll Timeline
.scroll-area {
overflow-y: auto;
scroll-timeline-name: --content-scroll;
scroll-timeline-axis: block;
}
Step 3: Expand the Timeline Scope
.layout {
timeline-scope: --content-scroll;
}
Step 4: Reference the Timeline
.progress-indicator {
animation: progress-grow linear both;
animation-timeline: --content-scroll;
}
Step 5: Define the Animation
@keyframes progress-grow {
from {
transform: scaleX(0);
}
to {
transform: scaleX(1);
}
}
The progress indicator can now use the scroll timeline defined on its sibling because both elements are descendants of the element that establishes the expanded timeline scope.
Important Consideration
The named timeline must still be defined by an appropriate timeline-generating element. Declaring timeline-scope alone does not produce scroll progress or animation movement.
The none Value
The none value does not expand the scope of any named timeline.
Basic Example
.container {
timeline-scope: none;
}
Default Behavior
Because none is the initial value, named timelines follow their normal scoping rules unless an expanded scope is explicitly established.
Restoring the Default
.layout {
timeline-scope: --content-scroll;
}
.layout.default-scope {
timeline-scope: none;
}
When to Use none
Use none to remove an expanded timeline scope established by another declaration on the same element.
Important Consideration
The none value does not disable existing scroll-driven animations or remove timeline definitions. It only controls expanded scoping established by this property.
Named Timeline Values
Named timelines use dashed identifiers, which are custom names beginning with two hyphens.
Single Timeline Name
.layout {
timeline-scope: --content-scroll;
}
Matching Timeline Definition
.scroll-area {
scroll-timeline-name: --content-scroll;
}
Matching Animation Reference
.progress-bar {
animation-timeline: --content-scroll;
}
Naming Requirements
The same timeline name must be used consistently in the timeline definition, expanded scope, and animation reference.
Different Names
.layout {
timeline-scope: --main-scroll;
}
.scroll-area {
scroll-timeline-name: --content-scroll;
}
These names do not match, so the expanded scope does not expose the named scroll timeline as intended.
When to Use Named Timelines
Named timelines are useful when the animated element and the scroll or view timeline source are separate elements.
Understanding Timeline Scoping
Timeline scoping determines which elements can reference a named animation timeline.
Normal Timeline Scope
Without an expanded scope, a named timeline is generally available to its defining element and elements within its normal timeline scope.
Sibling Elements
<div class="layout">
<div class="scroll-area">...</div>
<div class="progress-bar"></div>
</div>
The progress bar is not a descendant of the scroll area, so it cannot normally reference the scroll area's named timeline solely through their sibling relationship.
Expanded Timeline Scope
.layout {
timeline-scope: --content-scroll;
}
.scroll-area {
scroll-timeline-name: --content-scroll;
}
.progress-bar {
animation-timeline: --content-scroll;
}
Declaring the timeline name on the shared ancestor allows the named timeline to be referenced throughout the expanded scope.
Choosing the Correct Ancestor
Place timeline-scope on an ancestor containing both the timeline source and the elements that need to reference it.
Nested Containers
Expanded scopes can also be useful when timeline sources and animation targets appear in different nested branches of a component.
Scope Boundaries
Expanding a timeline scope does not make the named timeline globally available throughout the entire document. Its availability remains subject to the established scope and CSS timeline lookup rules.
Using Scroll Progress Timelines
A scroll progress timeline tracks the scrolling position of a scroll container and uses that progress to drive an animation.
Create a Scroll Container
.scroll-content {
height: 240px;
overflow-y: auto;
}
Define the Scroll Timeline
.scroll-content {
scroll-timeline-name: --reading-progress;
scroll-timeline-axis: block;
}
Expand the Scope
.reading-layout {
timeline-scope: --reading-progress;
}
Connect the Animation
.reading-progress {
transform-origin: left;
animation: reading-progress-grow linear both;
animation-timeline: --reading-progress;
}
Define the Keyframes
@keyframes reading-progress-grow {
from {
transform: scaleX(0);
}
to {
transform: scaleX(1);
}
}
How the Animation Progresses
As the scroll container moves through its scrollable range, the named scroll timeline advances and updates the progress indicator.
When to Use Scroll Timelines
Use scroll progress timelines for reading progress indicators, scroll-linked visual effects, and interfaces where animation progress should correspond to scrolling.
Using View Progress Timelines
A view progress timeline tracks the visibility of an element as it moves through a scrollport.
Define a View Timeline
.feature-section {
view-timeline-name: --feature-view;
view-timeline-axis: block;
}
Expand the Timeline Scope
.feature-layout {
timeline-scope: --feature-view;
}
Reference the Timeline
.feature-indicator {
animation: feature-fade linear both;
animation-timeline: --feature-view;
}
Define the Animation
@keyframes feature-fade {
from {
opacity: 0.3;
}
to {
opacity: 1;
}
}
How View Timelines Work
The animation progresses according to the subject element's movement through the relevant scrollport rather than elapsed clock time.
Scroll Versus View Timelines
| Timeline Type | Progress Based On |
|---|---|
| Scroll progress timeline | The scrolling position of a scroll container. |
| View progress timeline | The visibility progress of a subject within a scrollport. |
When to Use View Timelines
Use view progress timelines for effects that respond to elements entering, moving through, or leaving the visible scrolling area.
Multiple Named Timelines
The timeline-scope property can expand the scope of multiple named timelines using a comma-separated list.
Basic Example
.layout {
timeline-scope: --reading-scroll, --feature-view;
}
Define the Timelines
.reading-panel {
scroll-timeline-name: --reading-scroll;
}
.feature-section {
view-timeline-name: --feature-view;
}
Reference Different Timelines
.reading-indicator {
animation-timeline: --reading-scroll;
}
.feature-indicator {
animation-timeline: --feature-view;
}
Independent Animation Progress
Each animation follows the timeline referenced by its own animation-timeline declaration.
Adding More Names
.layout {
timeline-scope: --reading-scroll, --feature-view, --sidebar-scroll;
}
Important Consideration
Listing a timeline name does not automatically create that timeline. Each name must have an appropriate timeline definition for the intended animation to receive progress.
Related CSS Properties
The timeline-scope property works with several properties used to define and control scroll-driven animations.
scroll-timeline-name
.scroll-area {
scroll-timeline-name: --content-scroll;
}
Assigns a name to a scroll progress timeline.
scroll-timeline-axis
.scroll-area {
scroll-timeline-axis: block;
}
Specifies the axis used to measure scroll progress.
scroll-timeline
.scroll-area {
scroll-timeline: --content-scroll block;
}
Defines a named scroll progress timeline using shorthand syntax.
view-timeline-name
.section {
view-timeline-name: --section-view;
}
Assigns a name to a view progress timeline.
view-timeline-axis
.section {
view-timeline-axis: block;
}
Specifies the axis used to measure view progress.
view-timeline
.section {
view-timeline: --section-view block;
}
Defines a named view progress timeline using shorthand syntax.
animation-timeline
.indicator {
animation-timeline: --content-scroll;
}
Connects an animation to a named timeline.
animation-range
.animated-element {
animation-range: entry 0% exit 100%;
}
Defines the portion of an animation timeline used by an animation.
animation
.indicator {
animation: progress-grow linear both;
}
Specifies animation properties such as the animation name, timing function, and fill mode.
Complete Example
.layout {
timeline-scope: --content-scroll;
}
.scroll-area {
overflow-y: auto;
scroll-timeline: --content-scroll block;
}
.progress-bar {
transform-origin: left;
animation: progress-grow linear both;
animation-timeline: --content-scroll;
}
@keyframes progress-grow {
from {
transform: scaleX(0);
}
to {
transform: scaleX(1);
}
}
Inheritance
The timeline-scope property is not inherited. A descendant element does not automatically receive its parent's computed timeline-scope value.
Parent Element Example
.layout {
timeline-scope: --content-scroll;
}
Descendant Elements
Although the property is not inherited, the expanded timeline scope can still make the named timeline available to descendants of the declaring element.
Explicit Inheritance
.child {
timeline-scope: inherit;
}
This explicitly copies the parent's computed property value onto the child. It does not normally need to be used to make a named timeline available within an existing expanded scope.
Restore the Initial Value
.child {
timeline-scope: initial;
}
This restores none.
Using unset
.child {
timeline-scope: unset;
}
Because the property is not inherited, unset restores the initial value.
Important Distinction
Property inheritance and timeline scoping are different concepts. The property itself is not inherited, but the expanded scope established by an ancestor can make a named timeline accessible to its descendants.
Practical Examples
Reading Progress Indicator
.reading-layout {
timeline-scope: --reading-scroll;
}
.reading-content {
overflow-y: auto;
scroll-timeline-name: --reading-scroll;
}
.reading-progress {
animation: progress-grow linear both;
animation-timeline: --reading-scroll;
}
Scrollable Sidebar
.sidebar-layout {
timeline-scope: --sidebar-scroll;
}
.sidebar-content {
overflow-y: auto;
scroll-timeline: --sidebar-scroll block;
}
.sidebar-indicator {
animation-timeline: --sidebar-scroll;
}
View-Based Feature Animation
.feature-layout {
timeline-scope: --feature-view;
}
.feature-section {
view-timeline-name: --feature-view;
}
.feature-indicator {
animation-timeline: --feature-view;
}
Multiple Timeline Names
.dashboard {
timeline-scope: --main-scroll, --sidebar-scroll;
}
Named Timeline With Shorthand
.layout {
timeline-scope: --content-scroll;
}
.scroll-area {
scroll-timeline: --content-scroll block;
}
Named View Timeline With Shorthand
.layout {
timeline-scope: --section-view;
}
.section {
view-timeline: --section-view block;
}
Progressive Enhancement
@supports (timeline-scope: --content-scroll) and (animation-timeline: --content-scroll) {
.layout {
timeline-scope: --content-scroll;
}
.scroll-area {
scroll-timeline-name: --content-scroll;
}
.progress-bar {
animation-timeline: --content-scroll;
}
}
Multiple Animation Targets
.layout {
timeline-scope: --content-scroll;
}
.progress-bar,
.progress-icon {
animation-timeline: --content-scroll;
}
Multiple descendants can reference the same named timeline while using different keyframe animations.
timeline-scope Example
This example uses a named scroll progress timeline to animate a progress bar outside the scroll container. The scroll area and progress bar are siblings inside a shared layout.
HTML Example
<div class="timeline-scope-demo">
<div class="timeline-progress-track">
<div class="timeline-progress-bar"></div>
</div>
<div class="timeline-scroll-area">
<h3>Scroll This Content</h3>
<p>Scroll down to advance the progress indicator.</p>
<p>The progress bar is outside the scrolling element.</p>
<p>Both elements share the same ancestor.</p>
<p>The timeline-scope property expands the timeline scope.</p>
<p>The animation follows the scroll position.</p>
<p>Continue scrolling to reach the end.</p>
</div>
</div>
CSS Example
.timeline-scope-demo {
max-width: 420px;
timeline-scope: --demo-scroll;
}
.timeline-progress-track {
height: 8px;
margin-bottom: 12px;
overflow: hidden;
background: #e2e8f0;
}
.timeline-progress-bar {
width: 100%;
height: 100%;
background: #2563eb;
transform-origin: left;
animation: demo-progress linear both;
animation-timeline: --demo-scroll;
}
.timeline-scroll-area {
height: 180px;
padding: 16px;
overflow-y: auto;
border: 1px solid #cbd5e1;
background: #f8fafc;
scroll-timeline: --demo-scroll block;
}
.timeline-scroll-area h3 {
margin: 0 0 12px;
}
.timeline-scroll-area p {
margin: 0 0 18px;
}
@keyframes demo-progress {
from {
transform: scaleX(0);
}
to {
transform: scaleX(1);
}
}
Scroll This Content
Scroll down to advance the progress indicator.
The progress bar is outside the scrolling element.
Both elements share the same ancestor.
The timeline-scope property expands the timeline scope.
The animation follows the scroll position.
Continue scrolling to reach the end.
Understanding the Results
The scroll container defines the named timeline --demo-scroll. The shared ancestor expands that timeline's scope, allowing the progress bar to reference it.
Scroll Progress
As the content is scrolled, the progress bar grows horizontally. Its animation progress follows the scroll position rather than a fixed duration.
Why timeline-scope Is Needed
The progress bar is a sibling of the scroll container rather than a descendant. The expanded scope allows it to use the timeline defined by the scroll container.
Experiment With the Timeline Name
.timeline-scope-demo {
timeline-scope: --reading-progress;
}
.timeline-scroll-area {
scroll-timeline: --reading-progress block;
}
.timeline-progress-bar {
animation-timeline: --reading-progress;
}
All three declarations must use the matching timeline name for the example to work as intended.
Browser Compatibility
The live animation requires support for named scroll-driven timelines and the timeline-scope property. Unsupported browsers may display the progress track without a working scroll-linked animation.
Accessibility Considerations
Scroll-driven animations can provide useful visual feedback, but they should not be required to understand or operate the page.
Respect Reduced Motion Preferences
Some users prefer reduced animation. Use the prefers-reduced-motion media query to reduce or disable decorative effects.
@media (prefers-reduced-motion: reduce) {
.animated-element {
animation: none;
}
}
Avoid Essential Information in Animations
Do not rely on a scroll-driven animation as the only way to communicate important information.
Keep Scroll Containers Accessible
Scrollable content should remain usable with a keyboard and other input methods.
Avoid Excessive Movement
Large or rapidly changing animations may distract users or make content harder to follow.
Provide Clear Visual Feedback
Progress indicators should use sufficient contrast and remain understandable without unnecessary decorative effects.
Test Different Input Methods
Verify that scroll-linked effects behave appropriately with mouse wheels, touch gestures, keyboard scrolling, and assistive technology.
Provide Fallbacks
The page should remain functional when scroll-driven animations are unsupported or disabled.
Common Mistakes
Using auto Instead of none
.container {
timeline-scope: auto;
}
The auto keyword is not a valid value for this property.
Using all Instead of Timeline Names
.container {
timeline-scope: all;
}
The property requires none or explicit dashed timeline names.
Omitting Commas Between Names
.container {
timeline-scope: --first --second;
}
Use commas to separate multiple timeline names.
Combining none With a Name
.container {
timeline-scope: none, --content-scroll;
}
The none keyword must appear alone.
Using a Length Value
.container {
timeline-scope: 300px;
}
Length values are not accepted.
Expecting timeline-scope to Create a Timeline
The property only expands the scope of named timelines. Use scroll-timeline-name or view-timeline-name to define a timeline.
Using Mismatched Timeline Names
The timeline name must match across the scope declaration, timeline definition, and animation reference.
Placing the Scope on the Wrong Element
The declaring element must establish a scope that contains the timeline source and intended animation targets.
Forgetting animation-timeline
An animation must reference the intended named timeline to use its progress.
Forgetting to Define Keyframes
A timeline does not define the visual changes of an animation. Keyframes or another suitable animation effect must provide those changes.
Overriding animation-timeline With a Later Shorthand
.indicator {
animation-timeline: --content-scroll;
animation: progress-grow linear both;
}
The later animation shorthand resets animation-timeline. Declare animation-timeline after the shorthand.
Ignoring Browser Support
Scroll-driven animation features are not uniformly supported in older browsers.
Assuming the Property Is Inherited
The property is not inherited, even though an expanded scope can make timelines available to descendants.
Ignoring Reduced Motion Preferences
Provide an appropriate reduced-motion experience for decorative animations.
Important Considerations
Keep the following points in mind when using timeline-scope:
- The property expands the scope of named animation timelines.
- It is primarily used with scroll-driven animations.
- The initial value is
none. - The property is not inherited.
- It accepts dashed timeline names.
- Multiple names must be separated by commas.
- The
nonekeyword must appear alone. - The property does not create a timeline.
- Use
scroll-timeline-nameto define a named scroll progress timeline. - Use
view-timeline-nameto define a named view progress timeline. - Use
animation-timelineto connect an animation to a named timeline. - Timeline names must match across related declarations.
- The scope should be declared on an appropriate shared ancestor.
- Expanded scoping allows timeline references across descendant branches.
- Expanded scoping does not make a timeline globally available.
- Multiple animations can reference the same named timeline.
- Scroll progress timelines track scrolling position.
- View progress timelines track visibility progress.
- Animation progress follows the referenced timeline.
- The
animationshorthand resetsanimation-timeline. - Scroll-driven animation support varies between browsers.
- Use feature detection where appropriate.
- Provide functional fallbacks for unsupported browsers.
- Respect reduced-motion preferences.
- Test animations with different scroll containers and layouts.
Browser Support
The CSS timeline-scope property has limited availability compared with established CSS animation properties. Support depends on the browser's implementation of named scroll-driven animation timelines and expanded timeline scoping.
For current compatibility information, visit Can I Use? and search for timeline-scope.
Basic Declaration
.layout {
timeline-scope: --content-scroll;
}
Feature Detection
@supports (timeline-scope: --content-scroll) {
.layout {
timeline-scope: --content-scroll;
}
}
Checking Related Features
@supports (timeline-scope: --content-scroll) and (animation-timeline: --content-scroll) {
.layout {
timeline-scope: --content-scroll;
}
.progress-bar {
animation-timeline: --content-scroll;
}
}
Fallback Behavior
Browsers that do not recognize the property ignore its declaration. Animations relying on the expanded timeline scope may not run as intended.
Progressive Enhancement
Use scroll-driven animations to enhance an interface without making essential functionality depend on them.
Testing Recommendations
Test the complete animation, including the named timeline definition, expanded scope, and animation reference. Recognizing the property syntax does not guarantee that every scroll-driven animation scenario behaves identically across browsers.
Specifications
The timeline-scope property is defined in the Scroll-driven Animations Level 1 specification.
Scroll-driven Animations Level 1 - timeline-scope Property
The specification defines how named animation timelines can have their scope expanded and how those names are resolved by animation targets.
For additional documentation and examples, consult MDN Web Docs.
