CSS animation-range-end Property
The animation-range-end property specifies where an animation's attachment range ends along a scroll-driven animation timeline.
It works with animation-range-start to define the portion of a scroll or view timeline used by an animation. You can specify a percentage, length, or named timeline range to control when an animation reaches the end of its active range.
animation-range-end Syntax
selector {
animation-range-end: exit 75%;
}
The value identifies the ending attachment point along the associated animation timeline.
.default-end {
animation-range-end: normal;
}
.percentage-end {
animation-range-end: 80%;
}
.entry-end {
animation-range-end: entry 100%;
}
.exit-end {
animation-range-end: exit 75%;
}
.cover-end {
animation-range-end: cover 80%;
}
For multiple animations, specify a comma-separated list of ending attachment points.
.multiple {
animation-range-end: entry 100%, exit 50%;
}
The property also accepts the global CSS values inherit, initial, revert, revert-layer, and unset.
Property Values
| Value | Description |
|---|---|
normal |
Uses the normal ending boundary of the associated animation timeline. This is the initial value. |
80% |
Sets the ending attachment point at 80% of the associated timeline. |
150px |
Specifies an ending position using a length measured along the timeline's progress. |
cover 80% |
Ends at 80% of the view timeline's cover range. |
contain 100% |
Ends at the final boundary of the contain range. |
entry 100% |
Ends when the entry range reaches its final boundary. |
exit 50% |
Ends halfway through the exit range. |
entry-crossing 100% |
Ends at the final boundary of the entry-crossing range. |
exit-crossing 50% |
Ends halfway through the exit-crossing range. |
The property accepts normal, a supported <length-percentage> value, or a named timeline range with an optional offset.
When a named range is specified without an offset, the ending position defaults to 100% of that named range.
The property applies to all elements, is not inherited, and has an initial value of normal. Its computed value retains the specified ending range information, with lengths resolved according to CSS computed-value rules.
The animation-range-end property itself is not animatable.
How animation-range-end Works
Scroll-driven animations use progress along a scroll or view timeline instead of relying solely on elapsed time.
The animation-range-end property identifies the point at which the animation's attachment range finishes. Together with animation-range-start, it establishes the timeline interval used for playback.
@keyframes reveal {
from {
opacity: 0;
transform: translateY(30px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.reveal-box {
animation-name: reveal;
animation-duration: auto;
animation-timing-function: linear;
animation-fill-mode: both;
animation-timeline: view();
animation-range-start: entry 0%;
animation-range-end: entry 100%;
}
In supporting browsers, the animation starts when the element begins entering the viewing area and reaches its ending keyframe at the end of the entry range.
Changing animation-range-end to exit 100% extends the attachment range until the element has completely left the viewing area.
The same keyframes can therefore produce a faster or slower visual progression depending on how much scrolling occurs between the starting and ending attachment points.
Named Timeline Ranges
View timelines provide named ranges that describe how an element moves through the viewing area of a scroll container.
cover
The cover range extends from the subject first entering the viewing area until it has completely left.
.box {
animation-range-end: cover 75%;
}
The animation's ending attachment point occurs three-quarters of the way through the cover range.
contain
The contain range describes the interval when the subject is fully contained within the viewing area. For a subject larger than the viewing area, it describes the interval when the viewing area is fully covered by the subject.
.box {
animation-range-end: contain 100%;
}
entry
The entry range tracks the subject entering the viewing area.
.box {
animation-range-end: entry 100%;
}
For a subject smaller than the viewing area, this point occurs when the subject has fully entered.
exit
The exit range tracks the subject leaving the viewing area.
.box {
animation-range-end: exit 50%;
}
This sets the ending attachment point halfway through the exit range.
entry-crossing and exit-crossing
The entry-crossing and exit-crossing ranges describe the intervals during which the subject's leading and trailing edges cross the viewing area.
.box {
animation-range-end: entry-crossing 100%;
}
.other-box {
animation-range-end: exit-crossing 50%;
}
These ranges are especially useful when the subject is larger than the viewing area and its edges cross at different points from the ordinary entry and exit boundaries.
Percentages and Lengths
You can use percentages or supported lengths to specify the ending attachment point more precisely.
Percentage Values
.box {
animation-range-end: 80%;
}
This sets the ending attachment point at 80% of the associated timeline's progress.
When a percentage follows a named range, it is measured relative to that named range rather than necessarily the entire timeline.
.box {
animation-range-end: entry 75%;
}
Here, the animation ends three-quarters of the way through the entry range.
Length Values
.box {
animation-range-end: 150px;
}
Length values specify positions along the timeline using CSS length units. Their practical meaning depends on the timeline and its scroll geometry.
Percentages are often easier to maintain when the scrollable distance or subject size changes across screen sizes.
Named Range Without an Offset
.box {
animation-range-end: entry;
}
For animation-range-end, this is equivalent to entry 100%. The ending boundary of the named range is used when no percentage or length is provided.
Combining Start and End Positions
The animation-range-start and animation-range-end properties work together to determine the attachment interval.
.box {
animation-range-start: entry 0%;
animation-range-end: entry 100%;
}
This animation uses the complete entry range.
To extend the animation across more of the subject's movement through the viewing area, choose a later ending point.
.box {
animation-range-start: entry 0%;
animation-range-end: exit 100%;
}
Here, the animation begins as the subject enters and ends when it has completely exited.
Shortening the Attachment Range
.box {
animation-range-start: cover 20%;
animation-range-end: cover 60%;
}
The animation progresses only between 20% and 60% of the cover range.
A shorter attachment interval makes the animation complete over less scrolling, while a longer interval spreads the same keyframe progression across more scrolling.
Choose start and end positions in the intended timeline order. Reversed or coincident boundaries can produce behavior different from a normal forward-progressing animation.
Scroll and View Timelines
The animation-range-end property can be used with both scroll progress timelines and view progress timelines.
Scroll Progress Timelines
A scroll progress timeline tracks the scrolling position of a scroll container.
.progress-bar {
transform-origin: left;
animation: grow linear both;
animation-timeline: scroll();
animation-range-start: 0%;
animation-range-end: 80%;
}
@keyframes grow {
from {
transform: scaleX(0);
}
to {
transform: scaleX(1);
}
}
The progress bar reaches its full animated width when the associated scroll timeline reaches 80%, rather than waiting until the end of the scrollable range.
View Progress Timelines
A view progress timeline tracks an element's position relative to the viewing area.
.reveal-box {
animation: reveal linear both;
animation-timeline: view();
animation-range-start: entry 0%;
animation-range-end: entry 100%;
}
This animation finishes when the element reaches the end of its entry range.
Named ranges such as entry, exit, and contain are associated with view timelines. Percentages are commonly used to select positions along scroll progress timelines.
Multiple Animation End Ranges
When an element uses multiple scroll-driven animations, each animation can have a different ending attachment point.
.animated-element {
animation-name: fade-in, slide-in;
animation-duration: auto;
animation-timing-function: linear;
animation-fill-mode: both;
animation-timeline: view(), view();
animation-range-start: entry 0%, entry 0%;
animation-range-end: entry 100%, cover 75%;
}
The fade-in animation finishes at the end of the entry range. The slide-in animation continues until 75% of the cover range.
End range values are matched to the animations in the order specified by animation-name.
If fewer values are provided than animations, the list is repeated as needed when matching values to the animations.
.three-animations {
animation-name: fade, move, rotate;
animation-timeline: view(), view(), view();
animation-range-end: entry 100%, cover 75%;
}
Here, fade ends at entry 100%, move ends at cover 75%, and rotate ends at entry 100%.
animation-range-end Example
The following example compares two ending attachment points using the same view timeline animation. Scroll inside the demonstration to see how the squares move as their sections enter the viewing area.
The first square finishes at entry 100%. The second finishes later, at cover 75%.
<div class="range-end-demo" tabindex="0" aria-label="Scrollable animation range end demonstration">
<div class="range-end-spacer">Scroll down to view the animations</div>
<div class="range-end-item">
<strong>entry 100%</strong>
<div class="range-end-box early"></div>
</div>
<div class="range-end-spacer">Continue scrolling</div>
<div class="range-end-item">
<strong>cover 75%</strong>
<div class="range-end-box late"></div>
</div>
<div class="range-end-spacer">End of example</div>
</div>
.range-end-demo {
height: 250px;
overflow-y: auto;
border: 1px solid #ccc;
background-color: #f8f9fa;
}
.range-end-spacer {
min-height: 220px;
display: flex;
align-items: center;
justify-content: center;
padding: 15px;
box-sizing: border-box;
color: #555;
text-align: center;
}
.range-end-item {
min-height: 120px;
padding: 15px;
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
background-color: #fff;
}
.range-end-item strong {
display: block;
margin-bottom: 12px;
}
.range-end-box {
width: 50px;
height: 50px;
background-color: #1769aa;
}
@keyframes range-end-reveal {
from {
opacity: 0.3;
transform: translateX(0);
}
to {
opacity: 1;
transform: translateX(100px);
}
}
@supports (animation-timeline: view()) and (animation-range-end: entry 100%) {
.range-end-box {
animation-name: range-end-reveal;
animation-duration: auto;
animation-timing-function: linear;
animation-fill-mode: both;
animation-timeline: view();
animation-range-start: entry 0%;
}
.range-end-box.early {
animation-range-end: entry 100%;
}
.range-end-box.late {
animation-range-end: cover 75%;
}
}
@media (prefers-reduced-motion: reduce) {
.range-end-box {
animation: none;
}
}
Both squares use the same starting attachment point. Only their ending attachment points differ.
The first square completes its animation by the end of its entry range. The second continues progressing farther through its cover range before reaching the final keyframe.
Because both use animation-fill-mode: both, their starting and ending keyframe effects can remain visible outside the active attachment range.
In browsers without the required scroll-driven animation support, the squares remain visible and stationary. They also remain stationary when reduced motion is enabled.
Using the animation-range Shorthand
The animation-range shorthand combines animation-range-start and animation-range-end.
For example, these declarations:
.box {
animation-range-start: entry 0%;
animation-range-end: exit 75%;
}
Can be written as:
.box {
animation-range: entry 0% exit 75%;
}
Use the shorthand when both boundaries should be declared together. Use animation-range-end when only the ending boundary needs to change.
Declaring animation-range resets both of its longhand properties, so declaration order matters when combining the shorthand and longhands.
.box {
animation-range: entry 0% exit 100%;
animation-range-end: exit 50%;
}
Here, the final ending attachment point is exit 50% because the longhand declaration appears after the shorthand.
The general animation shorthand does not set animation-range-end, but it does reset animation-timeline. Declare the timeline after the animation shorthand.
Important Considerations
Keep the following points in mind when using animation-range-end:
- Default value: The initial value is
normal, which uses the normal ending boundary of the associated timeline. - Timeline selection: Use
animation-timelineto select the scroll or view timeline driving the animation. - Named ranges: Values such as
entry,exit, andcoveridentify phases of a view timeline. - Default named offset: A named range without an explicit offset uses its
100%boundary foranimation-range-end. - Percentages: Percentages following a named range are relative to that range, not necessarily the complete timeline.
- Start and end: Combine this property with
animation-range-startto establish the complete attachment interval. - Multiple animations: Comma-separated ending positions are matched to animations in their listed order.
- Browser compatibility: Scroll-driven animations have more limited support than traditional time-based CSS animations.
- Accessibility: Respect
prefers-reduced-motionand ensure content remains usable when animation support is unavailable.
Use animation-range-end when an animation should reach its final progress at a specific point during scrolling, such as when content finishes entering the viewport or a progress indicator reaches a selected scroll position.
Browser Support
The animation-range-end property has Limited availability and is not supported consistently across all major browsers.
Support depends on the browser's implementation of scroll-driven animations and their attachment ranges. Traditional CSS animation support does not guarantee support for this property.
Use @supports to provide enhanced animation behavior only when the required features are available.
@supports (animation-timeline: view()) and (animation-range-end: entry 100%) {
.box {
animation: reveal linear both;
animation-timeline: view();
animation-range-start: entry 0%;
animation-range-end: entry 100%;
}
}
Visit Can I Use? to check current browser compatibility.
Specifications
The animation-range-end property is defined in the CSS Scroll-Driven Animations Level 1 specification.
