Course contentsShow
← Web Development
Lesson 520 of 2,9829. CSS Transitions and AnimationsFree lesson

The animation-delay Property

Set a waiting period before an animation starts using positive or negative delays.

The animation-delay Property

You'll learn how to control when your CSS animations start by setting a waiting period before they begin.

What Is animation-delay?

When you create a CSS animation with @keyframes, it normally starts playing immediately when the page loads or when the element is added to the DOM. The animation-delay property lets you postpone that start time, creating a pause before the animation kicks in.

Think of it like a countdown timer: you press "start," but the action doesn't begin until a few seconds have passed.

Syntax and Values

.element {
  animation-name: fadeIn;
  animation-duration: 2s;
  animation-delay: 1s; /* Wait 1 second before starting */
}

The delay accepts time values in seconds (s) or milliseconds (ms). A positive value creates a waiting period:

animation-delay: 0.5s;  /* Half-second delay */
animation-delay: 500ms; /* Same thing */
animation-delay: 0s;    /* No delay (default) */

Negative Delays

Here's where it gets interesting: you can use negative values. A negative delay makes the animation start immediately, but partway through its sequence—as if it had already been running in the background.

animation-delay: -1s; /* Start 1 second "into" the animation */

If your animation is 3 seconds long and you set animation-delay: -1s, it will appear to start at the 1-second mark and play the remaining 2 seconds.

Practical Use Cases

Use positive delays to stagger animations (having multiple elements animate one after another) or to coordinate timing with other page events. Use negative delays when you want an animation to appear already in progress.

Key Takeaway: The animation-delay property sets a waiting period before an animation starts—positive values pause before beginning, while negative values start the animation partway through its cycle.