CSS animation-timing-function Property

Beginner
⏱️ 7 min read
📚 Updated: Jun 2026
🎯 4 Examples
Animations & Keyframes

What You’ll Learn

The animation-timing-function property shapes how fast an animation moves between keyframes. It controls acceleration and deceleration, not the total duration.

01

Speed Curves

Control animation pacing.

02

Keywords

ease, linear, and more.

03

Default ease

Smooth start and finish.

04

ease-in / ease-out

Enter and exit motion.

05

cubic-bezier()

Custom motion curves.

06

steps()

Jump between frames.

Definition and Usage

The animation-timing-function CSS property defines how intermediate values are calculated during an animation. It controls the speed curve, meaning how quickly the animation accelerates, decelerates, or stays constant over time.

Two animations can have the same duration and keyframes but feel completely different because of their timing function. A menu slide might use ease-out to slow down gently at the end, while a loader might use linear for steady rotation.

💡
Beginner Tip

Timing function controls how speed changes. animation-duration controls how long the animation takes. You usually need both.

📝 Syntax

Set animation-timing-function to a keyword, steps(), or cubic-bezier():

syntax.css
selector {
  animation-timing-function: timing-function;
}

Basic Example

animation-timing-function.css
@keyframes move {
  0% { left: 0; }
  100% { left: 300px; }
}

.box {
  animation-name: move;
  animation-duration: 4s;
  animation-iteration-count: infinite;
  animation-timing-function: ease-in-out;
}

Syntax Rules

  • The initial value is ease.
  • Keyword values include linear, ease-in, ease-out, and ease-in-out.
  • cubic-bezier(x1, y1, x2, y2) creates a custom curve with four control points.
  • steps(n, start|end) divides the animation into discrete jumps.
  • For multiple animations, list timing functions in the same order as animation-name.

⚡ Quick Reference

QuestionAnswer
Initial valueease
Applies toElements with CSS animations
InheritedNo
AnimatableNo
Common useNatural motion, UI entrances, loaders, and custom animation pacing

Default Value

The initial value of animation-timing-function is ease. The animation starts slowly, speeds up in the middle, and slows down again before finishing.

💎 Property Values

These are the timing functions you will use most often when building animations.

ValueExampleMeaning
easeanimation-timing-function: ease;Default curve: slow start, faster middle, slow finish
linearanimation-timing-function: linear;Constant speed from start to finish
ease-inanimation-timing-function: ease-in;Starts slowly, then speeds up
ease-outanimation-timing-function: ease-out;Starts quickly, then slows down at the end
ease-in-outanimation-timing-function: ease-in-out;Slow at both ends, faster in the middle
step-startanimation-timing-function: step-start;Jumps immediately to the end state at the start
step-endanimation-timing-function: step-end;Holds the start state, then jumps at the end
steps()animation-timing-function: steps(4, end);Advances in a fixed number of discrete steps
cubic-bezier()animation-timing-function: cubic-bezier(0.1, 0.7, 0.9, 0.3);Custom speed curve defined by four control values
linear

The box moves at a steady, constant speed across the track.

Constant speed

Best for loaders and mechanical motion.

ease-in

The box starts slowly and accelerates toward the end of the track.

Slow start, fast finish

Good for elements leaving the screen.

ease-out

The box moves quickly at first, then decelerates as it reaches the end.

Fast start, slow finish

Popular for menus and modal entrances.

ease-in-out

The box starts and ends slowly with faster movement in the middle.

Smooth at both ends

Balanced choice for sliding UI elements.

Timing Function vs Duration

These two properties work together but control different things:

PropertyControlsExample question it answers
animation-durationTotal time the animation takes“How long should this run?”
animation-timing-functionHow speed changes during that time“Should it start fast or slow?”

A 2-second animation with linear moves evenly for the full 2 seconds. The same 2-second animation with ease-in still lasts 2 seconds, but most of the visible movement happens near the end.

Understanding cubic-bezier()

cubic-bezier(x1, y1, x2, y2) lets you design a custom easing curve. Each value is between 0 and 1 for the control points that shape acceleration:

cubic-bezier.css
.card {
  animation: slideUp 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

Common presets like ease and ease-in-out are built-in cubic-bezier curves. Custom values are useful when you want a snappier or more playful feel than the keywords provide.

linear vs ease-in-out

ValueSpeed patternBest for
linearSame speed throughoutSpinners, progress bars, marquee text
ease-in-outSlow start and end, faster middleSliding panels, cards, and natural UI motion

👀 Live Preview

This box uses animation-timing-function: ease-in-out with animation-direction: alternate:

The box slows down at both ends of each slide, creating smoother back-and-forth motion.

Examples Gallery

Try animation-timing-function with ease-in-out motion, linear vs ease comparison, custom cubic-bezier curves, and stepped animation.

📚 Keyword Timing Functions

Start with built-in keywords before moving to custom curves.

Example 1 — Smooth Motion with ease-in-out

Move a box across the screen with slow starts and finishes at both ends.

animation-timing-function-ease-in-out.html
<style>
  @keyframes move {
    0% { left: 0; }
    100% { left: 300px; }
  }
  .box {
    width: 100px;
    height: 100px;
    background-color: blue;
    position: relative;
    animation-name: move;
    animation-duration: 4s;
    animation-iteration-count: infinite;
    animation-timing-function: ease-in-out;
  }
</style>

<div class="box"></div>
Try It Yourself

How It Works

The box still takes 4 seconds per cycle, but ease-in-out makes the movement gentle at the start and end.

Example 2 — Compare linear and ease-out

Two boxes with the same duration show how different timing functions feel.

animation-timing-function-compare.css
.linear-box {
  animation: move 3s linear infinite;
}

.ease-out-box {
  animation: move 3s ease-out infinite;
}
Try It Yourself

How It Works

Both animations finish in 3 seconds, but ease-out spends more visible movement time at the beginning.

⚡ Custom Curves

Go beyond keywords with cubic-bezier and steps timing functions.

Example 3 — Custom Curve with cubic-bezier()

Create a snappy entrance with a custom easing curve.

animation-timing-function-bezier.css
.toast {
  animation: slideUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
Try It Yourself

How It Works

The custom bezier curve controls how quickly the toast rises and fades in during the 0.5 second duration.

Example 4 — Stepped Animation with steps()

Break smooth motion into discrete jumps for a flipbook-style effect.

animation-timing-function-steps.css
.loader {
  animation: progress 2s steps(4, end) infinite;
}
Try It Yourself

How It Works

steps(4, end) divides the 2-second animation into four visible jumps instead of smooth continuous growth.

🧠 How animation-timing-function Works

1

Keyframes define states

You set the start and end values, such as translateX(0) to translateX(200px).

Keyframes
2

Duration sets total time

animation-duration decides how long the full animation cycle lasts.

Duration
3

Timing function shapes speed

The browser distributes progress using your chosen curve, such as ease-out or cubic-bezier().

Curve
=

Natural-looking motion

The same keyframes can feel mechanical, smooth, or playful depending on the timing function.

Universal Browser Support

animation-timing-function is supported in all modern browsers alongside CSS animations.

Baseline · CSS Animations

Control animation curves in modern browsers

Chrome, Firefox, Safari, Edge, and Opera support keyword timing functions, cubic-bezier(), and steps().

98% Modern browser support
Google Chrome43+ · Desktop & Mobile
Full support
Mozilla Firefox16+ · Desktop & Mobile
Full support
Apple Safari9+ · macOS & iOS
Full support
Microsoft Edge12+ · Modern versions
Full support
Opera30+ · Modern versions
Full support

Legacy browsers

Very old browsers without CSS animation support also lack timing function control.

💻
Internet Explorer IE 9 and earlier · No CSS animation support
None
animation-timing-function property 98% supported

Bottom line: Use keyword curves for most UI motion and cubic-bezier for custom polish.

Conclusion

The animation-timing-function property gives you fine control over animation pacing. Keywords like ease-out and ease-in-out cover most UI needs, while cubic-bezier() and steps() unlock custom and frame-based motion.

Pair timing functions with clear keyframes and appropriate durations to create animations that feel smooth, responsive, and professional.

💡 Best Practices

✅ Do

  • Use ease-out for elements entering the screen
  • Use linear for spinners and continuous loops
  • Try ease-in-out for sliding panels and cards
  • Test motion with real duration values, not just defaults
  • Respect prefers-reduced-motion for accessibility

❌ Don’t

  • Confuse timing function with animation duration
  • Use linear for every UI animation by default
  • Overuse extreme cubic-bezier values without testing
  • Forget that steps() creates jumps, not smooth motion
  • Mix up comma-separated order when using multiple animations

Key Takeaways

Knowledge Unlocked

Five things to remember about animation-timing-function

Use these points when shaping animation speed curves.

5
Core concepts
02

Default ease

Smooth start and finish.

Default
🔄03

Keywords

linear, ease-in, ease-out.

Syntax
🎯04

cubic-bezier()

Custom motion curves.

Advanced
📚05

steps()

Frame-by-frame jumps.

Special

❓ Frequently Asked Questions

The animation-timing-function property controls the speed curve of an animation. It defines how quickly or slowly the animation progresses between keyframes over its duration.
The initial value is ease, which starts slowly, speeds up in the middle, and slows down again before finishing.
animation-duration sets how long the animation takes. animation-timing-function sets how the speed changes during that time, such as constant speed with linear or slow start with ease-in.
Use cubic-bezier() when predefined keywords like ease or ease-in-out do not match the motion you want. It lets you create custom acceleration and deceleration curves.
The steps() function breaks an animation into discrete jumps instead of smooth motion. It is useful for sprite sheets, flipbook-style effects, and stepped progress indicators.

Practice in the Live Editor

Open the HTML editor and experiment with linear, ease-in-out, and cubic-bezier() curves.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful