🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Expert Masterclasses.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
REFERENCEcss

css Documentation

LOADING ENGINE...

CSS animation-duration

Control time itself. Learn how to set the speed of your CSS animations using seconds and milliseconds.

style.css
.box {
animation-name: slide;
animation-duration: 2s;
}
/* Result: Moves for 2s */
⏱️
animation.css
1 / 8
⚙️

Tutor:To create an animation, we first define keyframes. Here is a simple slide effect.


Animation Mastery

Unlock nodes by learning timing, duration, and keyframes.

Concept 1: Animation Duration

The animation-duration property defines how many seconds or milliseconds an animation takes to complete one cycle. Without specifying this, the default is 0s, meaning no animation will occur.

System Check

What is the default animation-duration?


Community Motion Lab

Share Animation Snippets

Created a cool keyframe effect? Share your timing functions and durations.

Enjoying this guide?

Codesyllabus is 100% free and open-source. Support our mission, pay for server infrastructure, and fuel new tutorials by buying us a coffee!

CSS Animation Duration

Author

Pascual Vila

Frontend Instructor.

The animation-duration property defines how long an animation takes to complete one cycle. Without this property, no animation will occur, as the default value is 0s.

Time Units

You can specify the duration in seconds (s) or milliseconds (ms).

  • 1s = 1 second
  • 100ms = 0.1 seconds
  • 1000ms = 1 second

Syntax

You can set it explicitly or via the shorthand:

/* Explicit */
animation-duration: 3s;

/* Shorthand */
animation: slide 3s infinite;

Best Practices

Avoid extremely fast animations (under 100ms) unless for micro-interactions, as they can be imperceptible. Conversely, extremely long animations (over 5s) might lose the user's attention. A standard UI transition is usually between 200ms and 500ms.

Animation Glossary

animation-duration
Specifies the length of time that an animation takes to complete one cycle. Default is 0s.
@keyframes
Specifies the animation code. The animation is created by gradually changing from one set of CSS styles to another.
ms (Milliseconds)
A unit of time equal to one thousandth of a second. Useful for fine-tuning UI animations.
animation-name
Specifies the name of the @keyframes animation to bind to the selector.