CSS animation-timing-function Property
The animation-timing-function property controls how an animation progresses between keyframes.
It determines whether an animation moves at a constant pace, accelerates, decelerates, or changes in discrete steps. Timing functions affect the rate of progress without changing the animation's specified duration.
animation-timing-function Syntax
selector {
animation-timing-function: ease-in-out;
}
The property accepts predefined easing keywords and functions that define custom timing behavior.
.default-timing {
animation-timing-function: ease;
}
.constant-speed {
animation-timing-function: linear;
}
.slow-start {
animation-timing-function: ease-in;
}
.slow-end {
animation-timing-function: ease-out;
}
.slow-start-and-end {
animation-timing-function: ease-in-out;
}
.custom-curve {
animation-timing-function: cubic-bezier(0.42, 0, 0.58, 1);
}
.discrete-steps {
animation-timing-function: steps(5, end);
}
.custom-linear {
animation-timing-function: linear(0, 0.4 40%, 1);
}
Multiple timing functions can be specified using a comma-separated list.
.multiple {
animation-timing-function: ease-in, linear, steps(4, end);
}
The property also accepts CSS-wide values such as inherit, initial, revert, revert-layer, and unset.
Property Values
| Value | Description |
|---|---|
ease |
Starts slowly, accelerates, and slows toward the end. This is the initial value. |
linear |
Progresses at a constant rate between keyframes. |
ease-in |
Starts slowly and accelerates toward the end. |
ease-out |
Starts quickly and decelerates toward the end. |
ease-in-out |
Starts and ends slowly, with faster progress in the middle. |
cubic-bezier() |
Defines a custom cubic Bézier easing curve using four numeric coordinates. |
steps() |
Divides animation progress into discrete steps instead of continuous movement. |
step-start |
Equivalent to steps(1, start). Jumps to the next value at the beginning of the interval. |
step-end |
Equivalent to steps(1, end). Jumps to the next value at the end of the interval. |
linear() |
Defines a piecewise linear easing function using a series of progress stops. |
The property applies to all elements, including ::before and ::after pseudo-elements. It is not inherited, its initial value is ease, and the property itself is not animatable.
Its computed value is the specified list of timing functions, with keyword aliases represented by their corresponding easing functions.
How animation-timing-function Works
A CSS animation uses keyframes to define property values at different points in its progress. The timing function determines how progress is distributed between those keyframes.
For example, an element moving 200 pixels over four seconds can travel at a constant rate or spend more time near the beginning and end of its movement.
@keyframes move-right {
from {
transform: translateX(0);
}
to {
transform: translateX(200px);
}
}
.box {
animation-name: move-right;
animation-duration: 4s;
animation-timing-function: ease-in-out;
}
The animation still lasts four seconds. The timing function changes how quickly the element moves during different portions of those four seconds.
Timing functions operate between keyframes. When an animation contains several keyframe intervals, easing is applied separately to each interval.
The timing function also works with scroll-driven animations, where easing adjusts how animation progress responds to timeline progress instead of elapsed time.
Easing Keywords
CSS provides several predefined easing keywords for common animation effects.
ease
The default ease value starts slowly, accelerates, and slows toward the end. It works well for many general interface animations.
.box {
animation-timing-function: ease;
}
linear
The linear keyword produces constant progress between keyframes. It is useful for continuous rotation, progress indicators, and other effects that should not accelerate or decelerate.
.spinner {
animation: spin 2s linear infinite;
}
ease-in
The ease-in value begins slowly and accelerates toward the end of the keyframe interval.
.box {
animation-timing-function: ease-in;
}
ease-out
The ease-out value begins quickly and slows toward the end. It is commonly used for elements entering or settling into position.
.box {
animation-timing-function: ease-out;
}
ease-in-out
The ease-in-out value begins and ends slowly, with faster progress in the middle.
.box {
animation-timing-function: ease-in-out;
}
The best easing function depends on the effect. For example, constant rotation usually benefits from linear, while a short interface movement may feel more natural with ease-out.
Using cubic-bezier()
The cubic-bezier() function defines a custom easing curve using two control points.
.box {
animation-timing-function: cubic-bezier(0.42, 0, 0.58, 1);
}
The four values represent the coordinates of the two control points: x1, y1, x2, and y2.
The starting point of the curve is fixed at (0, 0), and the ending point is fixed at (1, 1).
The first and third values, representing the x-coordinates, must be between 0 and 1. The y-coordinates can extend outside that range, allowing effects that overshoot or temporarily reverse progress.
Custom Acceleration
.fast-start {
animation-timing-function: cubic-bezier(0.1, 0.7, 0.3, 1);
}
.slow-start {
animation-timing-function: cubic-bezier(0.7, 0, 1, 0.5);
}
The first curve advances quickly near the beginning. The second delays much of its progress until later in the interval.
Overshoot Effects
.overshoot {
animation-timing-function: cubic-bezier(0.3, 1.4, 0.7, 1);
}
A control point with a y-coordinate greater than 1 can produce progress beyond the final keyframe value before returning to it. The visible result depends on the animated property and how its values are interpolated.
Several easing keywords are equivalent to predefined cubic Bézier curves:
| Keyword | Equivalent Function |
|---|---|
ease |
cubic-bezier(0.25, 0.1, 0.25, 1) |
linear |
cubic-bezier(0, 0, 1, 1) |
ease-in |
cubic-bezier(0.42, 0, 1, 1) |
ease-out |
cubic-bezier(0, 0, 0.58, 1) |
ease-in-out |
cubic-bezier(0.42, 0, 0.58, 1) |
Using steps()
The steps() function divides animation progress into discrete jumps instead of smoothly interpolating between values.
.box {
animation-timing-function: steps(5, end);
}
The first argument specifies the number of steps. The optional second argument determines where the jumps occur within the interval.
| Position | Description |
|---|---|
jump-start |
Includes a jump at the beginning of the interval. |
jump-end |
Includes a jump at the end of the interval. This is the default. |
jump-none |
Excludes jumps at both ends of the interval. At least two steps are required. |
jump-both |
Includes jumps at both ends of the interval. |
start |
Equivalent to jump-start. |
end |
Equivalent to jump-end. |
Step-Based Movement
@keyframes step-move {
from {
transform: translateX(0);
}
to {
transform: translateX(200px);
}
}
.box {
animation: step-move 2s steps(5, end) infinite;
}
The element moves through five discrete progress steps instead of sliding continuously.
step-start and step-end
.immediate-change {
animation-timing-function: step-start;
}
.delayed-change {
animation-timing-function: step-end;
}
These keywords each use a single step. With step-start, the value jumps at the beginning of the interval. With step-end, it changes at the end.
Step-based timing is useful for frame-by-frame sprite animations, counters, and effects where intermediate values should not appear.
Using linear()
The linear() function defines a piecewise linear easing curve using a sequence of output progress values and optional input positions.
Unlike the linear keyword, which represents constant progress, linear() can create custom acceleration, pauses, and changes in direction.
.box {
animation-timing-function: linear(0, 0.4 40%, 1);
}
This function progresses from 0 to 0.4 over the first 40% of the interval, then progresses from 0.4 to 1 over the remaining 60%.
Creating a Pause
.pause-effect {
animation-timing-function: linear(0, 0.5 40%, 0.5 60%, 1);
}
Between 40% and 60% of the interval, output progress remains at 0.5, creating a temporary pause in the interpolated movement.
Creating an Overshoot
.overshoot-effect {
animation-timing-function: linear(0, 1.15 75%, 1);
}
The output progresses beyond 1 before returning to the final value. This can create a simple overshoot effect.
The linear() function is useful when a cubic Bézier curve cannot easily represent the desired timing behavior. It is newer than the traditional easing keywords, so check browser compatibility before relying on it.
Timing Functions Within Keyframes
You can specify animation-timing-function inside a @keyframes rule to control individual intervals of an animation.
@keyframes custom-movement {
0% {
transform: translateX(0);
animation-timing-function: ease-in;
}
50% {
transform: translateX(100px);
animation-timing-function: ease-out;
}
100% {
transform: translateX(200px);
}
}
.box {
animation: custom-movement 4s linear infinite;
}
The ease-in function applies from the 0% keyframe to the 50% keyframe. The ease-out function applies from 50% to 100%.
A timing function declared in a keyframe applies to the interval beginning at that keyframe. A timing function declared at the final 100% keyframe has no following interval in that iteration.
When an interval has no keyframe-specific timing function, the animation uses the timing function specified on the animated element.
This technique allows a single animation to accelerate during one section and decelerate during another without creating separate animations.
Multiple Animation Timing Functions
When an element has several animations, each animation can use a different timing function.
.animated-element {
animation-name: move, fade, rotate;
animation-duration: 2s, 3s, 4s;
animation-timing-function: ease-in, linear, steps(8, end);
}
The move animation uses ease-in, fade uses linear, and rotate uses steps(8, end).
Timing functions are matched to animations in the order specified by animation-name.
If fewer timing functions are supplied than animations, the list repeats as needed.
.three-animations {
animation-name: move, fade, rotate;
animation-timing-function: ease-in, linear;
}
Here, move uses ease-in, fade uses linear, and rotate uses ease-in.
You can also specify timing functions through the animation shorthand.
.box {
animation: move 2s ease-in, fade 3s linear;
}
animation-timing-function Example
The following example compares five common timing functions. Each square travels the same distance over the same duration, but its speed changes according to the selected easing function.
All five animations restart together every four seconds, making their differences easier to compare.
<div class="timing-demo">
<div class="timing-row">
<strong>linear</strong>
<div class="timing-track"><div class="timing-box linear"></div></div>
</div>
<div class="timing-row">
<strong>ease</strong>
<div class="timing-track"><div class="timing-box ease"></div></div>
</div>
<div class="timing-row">
<strong>ease-in</strong>
<div class="timing-track"><div class="timing-box ease-in"></div></div>
</div>
<div class="timing-row">
<strong>ease-out</strong>
<div class="timing-track"><div class="timing-box ease-out"></div></div>
</div>
<div class="timing-row">
<strong>steps(5)</strong>
<div class="timing-track"><div class="timing-box steps"></div></div>
</div>
</div>
.timing-demo {
display: grid;
gap: 12px;
}
.timing-row {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 8px;
}
.timing-row strong {
flex: 0 0 70px;
}
.timing-track {
flex: 1 1 160px;
min-width: 0;
height: 36px;
padding: 4px;
background-color: #f1f3f5;
border: 1px solid #ccc;
box-sizing: border-box;
}
.timing-box {
width: 28px;
height: 26px;
background-color: #1769aa;
animation-name: timing-move;
animation-duration: 4s;
animation-iteration-count: infinite;
animation-direction: alternate;
}
.timing-box.linear {
animation-timing-function: linear;
}
.timing-box.ease {
animation-timing-function: ease;
}
.timing-box.ease-in {
animation-timing-function: ease-in;
}
.timing-box.ease-out {
animation-timing-function: ease-out;
}
.timing-box.steps {
animation-timing-function: steps(5, end);
}
@keyframes timing-move {
from {
transform: translateX(0);
}
to {
transform: translateX(100px);
}
}
@media (prefers-reduced-motion: reduce) {
.timing-box {
animation: none;
}
}
Because every animation uses the same keyframes and duration, the visible differences come from their timing functions.
The linear square moves at a constant rate. The ease, ease-in, and ease-out squares change speed during each interval. The steps(5, end) square moves in five discrete jumps.
All five squares reach the same ending position at the same time, despite their different movement patterns. When reduced motion is enabled, the squares remain stationary.
Important Considerations
Keep the following points in mind when using animation-timing-function:
- Default value: The initial value is
ease, notlinear. - Duration: Timing functions change the distribution of progress without changing the specified animation duration.
- Keyframe intervals: Easing applies between keyframes, so animations with intermediate keyframes can have several independently eased intervals.
- Constant progress: Use
linearfor continuous effects such as rotation and scroll progress indicators. - Custom curves: Use
cubic-bezier()when predefined easing keywords do not provide the desired movement. - Discrete movement: Use
steps()for effects that should change in jumps rather than continuously. - Piecewise easing: Use
linear()for custom progress stops, pauses, and overshoot effects. - Multiple animations: Comma-separated timing functions are matched to animations in their listed order.
- Animation shorthand: The
animationshorthand includes timing functions and can reset the longhand property when redeclared. - Scroll-driven animations: Timing functions also affect how keyframe progress is mapped to scroll or view timeline progress.
- Accessibility: Respect
prefers-reduced-motion, especially for continuous or repeated movement.
Choose timing functions based on how an animation should feel and behave. Simple easing keywords work well for most effects, while custom functions provide additional control when needed.
Browser Support
The animation-timing-function property has Baseline Widely available status and is supported across modern versions of Chrome, Edge, Firefox, Safari, and other major browsers.
Traditional easing keywords, cubic-bezier(), and steps() have broad support. The newer linear() easing function has a separate compatibility history and may not work in older browsers.
When using linear(), provide a compatible fallback if older browser support is required.
.box {
animation-timing-function: ease-out;
animation-timing-function: linear(0, 0.4 40%, 1);
}
Browsers that do not recognize linear() retain the earlier ease-out declaration.
Visit Can I Use? to check animation timing function compatibility. For the newer linear() function, search Can I Use? for linear() easing function.
Specifications
The animation-timing-function property is defined in CSS Animations Level 1. Timing function syntax, including easing functions, is also defined in CSS Easing Functions specifications.
