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

The animation-name Property

Connect elements to keyframe animations by referencing the animation name.

What You'll Learn

You'll learn how to link an HTML element to a specific keyframe animation using the animation-name property, bringing your animations to life.

Connecting Animations to Elements

In the previous lesson, you learned how to define animation sequences using @keyframes. But just creating a keyframe rule doesn't automatically apply it to anything—it's like writing a recipe that sits in a cookbook. The animation-name property is what actually tells an element which animation to perform.

Think of it like assigning a choreographer's routine to a dancer. The @keyframes rule is the choreography on paper, and animation-name is you saying "Hey, this dancer will perform that routine."

Basic Syntax

The animation-name property takes the exact name you gave your @keyframes rule:

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.welcome-message {
  animation-name: fadeIn;
  animation-duration: 2s;
}

In this example, any element with the class .welcome-message will now execute the fadeIn animation. Notice you still need other animation properties (like animation-duration) for the animation to actually run—animation-name just makes the connection.

Multiple Animations

You can even apply multiple animations to one element by separating animation names with commas:

.fancy-box {
  animation-name: slideIn, pulse;
  animation-duration: 1s, 2s;
}

The Default Value

If you don't specify animation-name, its default value is none, meaning no animation runs at all.

Key Takeaway: The animation-name property connects an element to a specific @keyframes animation by referencing its exact name, turning your animation definitions into actual motion on the page.