CSS animation-name Property

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

What You’ll Learn

The animation-name property connects an element to a named @keyframes animation. Without a matching name, the keyframes exist in CSS but nothing runs on the page.

01

Link Keyframes

Apply named animations.

02

Syntax

Custom keyframe names.

03

none

No animation applied.

04

@keyframes

Define motion first.

05

Multiple Names

Run more than one animation.

06

Shorthand

Name comes first.

Definition and Usage

The animation-name CSS property specifies which @keyframes animation should run on an element. You first define the animation steps with @keyframes, then use animation-name to attach that animation to a selector.

Think of @keyframes as writing the script and animation-name as choosing which actor performs it. You still need properties like animation-duration for the animation to be visible.

💡
Beginner Tip

The name in animation-name: fadeIn; must exactly match @keyframes fadeIn { ... }, including capitalization.

📝 Syntax

Set animation-name to none or one or more custom keyframe names:

syntax.css
selector {
  animation-name: none | keyframe-name;
}

Basic Example

animation-name.css
@keyframes changeColor {
  0% { background-color: blue; }
  100% { background-color: green; }
}

.animated-div {
  animation-name: changeColor;
  animation-duration: 2s;
}

Syntax Rules

  • The initial value is none, meaning no animation is applied.
  • The value must match a name declared in a @keyframes rule.
  • Keyframe names are case-sensitive: fadeIn and fadein are different.
  • You can list multiple names separated by commas for multiple simultaneous animations.
  • In the animation shorthand, the name is always the first value.

⚡ Quick Reference

QuestionAnswer
Initial valuenone
Applies toAll elements
InheritedNo
AnimatableNo
Common useConnecting elements to named @keyframes animations

Default Value

The initial value of animation-name is none. No animation runs until you assign a valid keyframe name and provide the other required animation properties.

💎 Property Values

These are the values you will use when applying named animations.

ValueExampleMeaning
noneanimation-name: none;No animation is applied to the element
Keyframe nameanimation-name: fadeIn;Uses the animation defined in @keyframes fadeIn
Multiple namesanimation-name: fadeIn, slideUp;Runs two animations on the same element
initialanimation-name: initial;Resets to the default value none
inheritanimation-name: inherit;Inherits the animation name from the parent element
changeColor

The element uses the @keyframes changeColor animation to shift background color.

@keyframes changeColor

Name must match exactly in both places.

slideIn

The same property can reference a movement animation defined separately in CSS.

@keyframes slideIn

Reuse one keyframe block on many selectors.

fadePulse

Different names let you organize animations by purpose, such as pulse, bounce, or fade.

@keyframes fadePulse

Choose descriptive names for easier maintenance.

How animation-name Works with @keyframes

Every animation needs two parts working together:

StepCSS ruleRole
1. Define@keyframes fadeIn { ... }Creates the animation steps and timing points
2. Applyanimation-name: fadeIn;Chooses which keyframe set the element uses
3. Configureanimation-duration: 1s;Sets how long the named animation runs

@keyframes vs animation-name

Rule / PropertyWhat it doesAnalogy
@keyframesDefines the animation stepsWriting the script
animation-nameSelects which keyframes to useChoosing which actor performs it

👀 Live Preview

This box uses a named keyframe animation via animation-name:

The background shifts between blue and green because the element is linked to matching @keyframes defined in CSS.

Examples Gallery

Try animation-name with a color animation, slide-in motion, multiple names, and shorthand syntax.

📚 Named Animations

Start by defining @keyframes, then connect them with animation-name.

Example 1 — Background Color Animation

Define @keyframes changeColor and apply it to a div with animation-name.

animation-name-color.html
<style>
  @keyframes changeColor {
    0% { background-color: blue; }
    100% { background-color: green; }
  }
  .animated-div {
    width: 100px;
    height: 100px;
    animation-name: changeColor;
    animation-duration: 2s;
    animation-iteration-count: infinite;
  }
</style>

<div class="animated-div"></div>
Try It Yourself

How It Works

The element runs the changeColor keyframes because animation-name points to that exact name.

Example 2 — Slide-In Entrance Animation

Reuse a named slide animation on a card component.

animation-name-slide.css
@keyframes slideIn {
  from { transform: translateX(-40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.card {
  animation-name: slideIn;
  animation-duration: 0.8s;
  animation-fill-mode: forwards;
}
Try It Yourself

How It Works

One @keyframes slideIn block can be shared by many elements that all use animation-name: slideIn.

Example 3 — Multiple Animation Names

Apply two named animations on the same element using a comma-separated list.

animation-name-multiple.css
.badge {
  animation-name: fadeIn, pulse;
  animation-duration: 0.6s, 1.2s;
  animation-iteration-count: 1, infinite;
}
Try It Yourself

How It Works

Each name in the list pairs with the matching value in animation-duration, animation-delay, and other animation properties.

⚡ Shorthand Usage

Put the animation name first in the animation shorthand.

Example 4 — Name in the Animation Shorthand

Use the shorthand when you want the name, duration, and timing in one line.

animation-shorthand-name.css
.toast {
  animation: fadeIn 0.5s ease-out forwards;
}
Try It Yourself

How It Works

In animation: fadeIn 0.5s ease-out forwards, the first value fadeIn is the animation name.

🧠 How animation-name Works

1

You create @keyframes

Define the animation steps under a custom name such as fadeIn.

Define
2

You set animation-name

Point the element to that keyframe name with animation-name: fadeIn;.

Connect
3

You add timing properties

Set duration, delay, iteration count, and fill mode so the named animation becomes visible.

Configure
=

Animated element

The browser runs the selected keyframes on the element using your animation settings.

Universal Browser Support

animation-name is supported in all modern browsers alongside CSS animations and @keyframes.

Baseline · CSS Animations

Apply named animations in modern browsers

Chrome, Firefox, Safari, Edge, and Opera all support custom animation names and multiple comma-separated names.

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 animation-name.

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

Bottom line: Define clear keyframe names and use the same spelling in animation-name for reliable results.

Conclusion

The animation-name property is the link between your @keyframes definitions and the elements that should animate. Without it, even well-written keyframes will not run.

Define descriptive names like fadeIn, slideUp, or spin, connect them with animation-name, and combine with duration and iteration settings to bring your UI to life.

💡 Best Practices

✅ Do

  • Use descriptive keyframe names like fadeIn or slideUp
  • Match the name exactly in @keyframes and animation-name
  • Define keyframes once and reuse them on multiple selectors
  • Pair animation-name with animation-duration
  • Keep multiple animation lists in the same order across properties

❌ Don’t

  • Misspell the keyframe name in animation-name
  • Forget that names are case-sensitive
  • Set animation-name without defining @keyframes
  • Use vague names like anim1 in large projects
  • Expect animation to run with only the name and no duration

Key Takeaways

Knowledge Unlocked

Five things to remember about animation-name

Use these points when connecting keyframes to elements.

5
Core concepts
📝02

Default none

No animation until named.

Default
🔗03

Exact Match

Name must equal @keyframes.

Rule
📈04

Reusable

One keyframe, many elements.

Pattern
05

Shorthand First

Name is first in animation.

Syntax

❓ Frequently Asked Questions

The animation-name property tells the browser which @keyframes animation to apply to an element.
The initial value is none, which means no animation runs until you assign a keyframe name.
Yes. The name in animation-name must match the identifier used in @keyframes, including spelling and case.
Yes. You can list multiple names separated by commas, and each name pairs with the other animation properties in the same order.
Yes. The animation name is the first value in the shorthand, for example animation: fadeIn 1s ease-out;

Practice in the Live Editor

Open the HTML editor, define @keyframes, and connect them with animation-name.

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