CSS animation-duration Property

Beginner
6 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The animation-duration property sets how long one cycle of an animation takes. The same @keyframes look faster with a short time and slower with a long time.

You still need an animation-name. The initial value is 0s, so without a positive duration you usually see no motion. It applies to all elements, including ::before and ::after, and it is not inherited. A duration does not remove motion for someone who set prefers-reduced-motion.

Standard-track.

Not deprecated. Time values in s and ms have been widely available since 2015. The auto keyword is newer and mainly matters for scroll-driven timelines; for a normal clock animation it acts like 0s.

CSS Syntax

syntax.css
animation-duration: 0s | 1s | 500ms | initial | inherit;

Any time with a unit, in seconds or milliseconds. Zero is allowed. Negative times are invalid. For several animations, separate the times with commas, in the same order as the names.

Property Values

ValueDescriptionTry it
0sInitial value. The cycle ends at once. With the default fill mode, you usually see no motionTry it
1sOne cycle takes one secondTry it
500msOne cycle takes half a second. Same length as 0.5sTry it
3sOne cycle takes three seconds. Same keyframes look slowerTry it
initialSets this property to its default value, 0sTry it
inheritInherits this property from the parent elementTry it

How to Use animation-duration

Name the animation, then set how long one play lasts.

  1. Write @keyframes fade from full opacity to 0.25.
  2. Set animation-name: fade.
  3. Set animation-duration to a time with a unit, such as 1s or 500ms.
  4. Optionally set animation-iteration-count so you can compare speeds over more than one play.
PieceRequired?Role
A named animationYesDuration has nothing to pace without @keyframes
A time with a unitYes1s or 500ms. A bare number is invalid
Positive timeTo see motion0s is the initial value and usually looks still

Live Preview

The same fade repeats. Only animation-duration changes. Apply again to restart from the start.

A longer duration makes the same fade look slower.

Result

Fade

animation-duration: 1s. One cycle takes one second.

CSS Examples

Each snippet uses the same fade. The only lesson is the duration. Use Try It Yourself for a live editor.

Example 1 — One Second

One full fade takes one second, then starts again.

CSS
<style>
  @keyframes fade {
    from {
      opacity: 1;
    }

    to {
      opacity: 0.25;
    }
  }

  p {
    animation-name: fade;
    animation-duration: 1s;
    animation-iteration-count: infinite;
  }
</style>

<p>Fade</p>
Try It Yourself

How It Works

  1. Name the steps. fade goes from opacity 1 to 0.25.
  2. Attach the name. animation-name: fade chooses those keyframes.
  3. Set the length. animation-duration: 1s spreads that change over one second.
  4. Repeat. infinite starts a new one-second play when the last one ends.

Example 2 — Half a Second

The same fade, but each cycle finishes in 500ms.

CSS
<style>
  @keyframes fade {
    from {
      opacity: 1;
    }

    to {
      opacity: 0.25;
    }
  }

  p {
    animation-name: fade;
    animation-duration: 500ms;
    animation-iteration-count: infinite;
  }
</style>

<p>Fade</p>
Try It Yourself

How It Works

  1. Keep the same keyframes. Only the duration changes.
  2. Use milliseconds. 500ms is half a second. It matches 0.5s.
  3. Watch the pace. The word dims twice as fast as the one-second example.
  4. Unit still required. Writing 500 alone is invalid and does nothing.

Example 3 — Fast vs Slow

Two lines share the same fade. One finishes in 1s. The other takes 3s.

CSS
<style>
  @keyframes fade {
    from {
      opacity: 1;
    }

    to {
      opacity: 0.25;
    }
  }

  p {
    animation-name: fade;
    animation-iteration-count: infinite;
  }

  .fast {
    animation-duration: 1s;
  }

  .slow {
    animation-duration: 3s;
  }
</style>

<p class="fast">Fast</p>
<p class="slow">Slow</p>
Try It Yourself

How It Works

  1. Share the animation. Both lines use fade and repeat forever.
  2. Give each a duration. Fast uses 1s. Slow uses 3s.
  3. Same path, different clock. The keyframes are identical. Only the length of one cycle changes.
  4. Read the difference. Slow looks calmer because each play lasts three times as long.

Edge Cases & Pitfalls

If nothing moves, the duration or the unit is usually why.

0s

The default looks still

The initial value is 0s. Events can still fire, but with the default animation-fill-mode of none you usually see no change. Set a positive time.

unit

A number alone is invalid

animation-duration: 1 is ignored. Write 1s or 1000ms. The unit is required.

minus

Negative times are invalid

Unlike animation-delay, a negative duration is dropped. Use 0s or a positive time.

order

The shorthand can wipe the duration

animation: fade without a time resets duration to 0s. Put the time in the shorthand, or write animation-duration after it.

list

One time per animation name

animation-duration: 1s, 3s follows the order of animation-name. Fewer times than names, and the list repeats.

Browser Support

animation-duration is a browser style property. Node.js, Deno, and Bun do not play it. The versions below are for time values in s and ms.

✓ Baseline · Widely available since 2015

animation-duration

Chrome 43+, Firefox 16+, Safari 9+, Edge 12+, Internet Explorer 10+. The auto keyword is newer (Chrome 115+, Safari 18.4+, Firefox 161+) and is not part of these numbers.

97% time values
Google Chrome 43+
Full support
Mozilla Firefox 16+
Full support
Apple Safari 9+
Full support
Microsoft Edge 12+
Full support
Opera 30+
Full support
Samsung Internet 4+
Full support
Internet Explorer 10+
Full support
animation-duration Widely supported

Bottom line: Older Chrome, Safari, and Firefox also accepted a prefixed property. Use a positive time with a unit for everyday animations. Treat auto as a newer scroll-timeline detail, not the default you teach first.

Key Takeaways

  • Role: how long one play of an animation lasts.
  • 0s: the initial value. Usually no visible motion until you set a positive time.
  • Units: 1s or 500ms. A bare number does nothing.
  • Not delay: duration is the length of the play. Delay is the wait before it.

One line: name the animation, then animation-duration sets the clock for one cycle.

Frequently Asked Questions

It sets how long one complete cycle of an animation takes. A longer time makes the same keyframes look slower. A shorter time makes them look faster.
The initial value is 0s. The animation still runs in the sense that start and end events fire, but with the default fill mode you usually see no motion.
Yes. Use seconds (s) or milliseconds (ms). 500ms is the same length as 0.5s. The unit is required.
Duration is how long one play lasts. Delay is how long to wait before that play starts. They are different properties.
No. A negative time is invalid and the declaration is ignored. Use 0s or a positive time with a unit.
Chrome 43+, Firefox 16+, Safari 9+, Edge 12+, and Internet Explorer 10 support time values in s and ms. It is a browser style property, not a Node.js feature. The auto keyword is newer.

Next: animation-fill-mode

Choose which keyframe styles stay before or after a play.

animation-fill-mode tutorial →

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.

8 people found this page helpful