CSS animation-name Property

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

Definition and Usage

The animation-name property chooses which @keyframes rule an element runs. The name is case-sensitive. If it does not match a keyframes rule, nothing animates.

The initial value is none. The property is not inherited, and it is not animatable: a new name takes effect in one step and restarts the animation. It applies to any element, including ::before and ::after.

Standard-track.

Not deprecated and not experimental. Baseline widely available since September 2015. Current browsers use the unprefixed property.

CSS Syntax

One name, or a comma-separated list. A name is an identifier such as slide, or a quoted string such as "slide".

syntax.css
animation-name: none | <custom-ident> | <string> | name, name | initial | inherit;

Property Values

ValueDescriptionTry it
noneNo keyframes. Turns that animation off. In a list, it clears one slot and leaves the other names in placeTry it
<custom-ident>Unquoted name, such as slide. Case-sensitive. It cannot be none, and it cannot start with --Try it
<string>Quoted name, such as "pop". Use quotes when the name is not a valid identifier. Quote it in @keyframes tooTry it
name, nameTwo or more animations on one element. Commas separate them. Spaces do notTry it
initialSets this property to its default value, noneTry it
inheritCopies the parent's name only. animation-duration is not inheritedTry it

unset equals initial here, so it is none. revert uses the user-agent value, which is also none.

How to Use animation-name

Write the keyframes, then point the element at that exact name. Give the animation a duration so you can see it.

  1. Add an @keyframes rule and give it a name.
  2. Set animation-name on the element to that same name, including capitals.
  3. Set animation-duration above 0s. The default is 0s, so a name alone looks like it did nothing.
  4. To run two animations, list both names with a comma. Pair duration, delay, and the other animation-* values in that same order.
PieceRequired?Role
@keyframes ruleYesStores the motion under a name
Matching nameYesCase-sensitive link from the element to that rule
animation-durationTo see itDefault 0s finishes before the motion is visible
Other animation-*NoTiming, count, delay, and direction. They do not choose the name

Live Preview

The box already has a 2 second duration and repeats. Change only animation-name and watch which keyframes run.

Duration stays at 2s. Only the keyframes name changes.

Preview
Box

animation-name: slide

CSS Examples

Each snippet sets a name and the duration you need to see it. The repeat only keeps the motion on screen. Use Try It Yourself for a live editor.

Example 1 — Name the Keyframes

Point the box at @keyframes slide.

CSS
<style>
  @keyframes slide {
    0% { transform: translateX(0); }
    50% { transform: translateX(120px); }
    100% { transform: translateX(0); }
  }
  div {
    width: 80px;
    height: 80px;
    background: #1d4ed8;
    animation-name: slide;
    animation-duration: 2s;
    animation-iteration-count: infinite;
  }
</style>

<div>Slide</div>
Try It Yourself

How It Works

  1. Name the motion. @keyframes slide stores a move to the right and back under the name slide.
  2. Point at that name. animation-name: slide tells the div to use those keyframes. Slide or SLIDE would not match.
  3. Give it time. animation-duration: 2s is what makes the move visible. The default duration is 0s.
  4. Keep it on screen. animation-iteration-count: infinite repeats the move so you can study it. The count does not choose which animation runs. The name does.

Example 2 — Turn an Animation Off

Same keyframes and the same duration. Only the name changes.

CSS
<style>
  @keyframes slide {
    0% { transform: translateX(0); }
    50% { transform: translateX(120px); }
    100% { transform: translateX(0); }
  }
  div {
    width: 80px;
    height: 80px;
    background: #1d4ed8;
    animation-duration: 2s;
    animation-iteration-count: infinite;
  }
  .on { animation-name: slide; }
  .off { animation-name: none; }
</style>

<div class="on">On</div>
<div class="off">Off</div>
Try It Yourself

How It Works

  1. One set of keyframes. @keyframes slide is available to both boxes.
  2. Same timing. Both set a 2s duration and an infinite count. Timing is not what splits them.
  3. The name is the switch. .on uses slide, so that box moves. .off uses none, so its keyframes are not applied.
  4. none is a real value. It is also the initial value. Use it to turn an animation off without deleting the @keyframes rule.

Example 3 — Two Names at Once

Move and fade the same box. One duration covers both names.

CSS
<style>
  @keyframes slide {
    0% { transform: translateX(0); }
    50% { transform: translateX(120px); }
    100% { transform: translateX(0); }
  }
  @keyframes fade {
    0% { opacity: 1; }
    50% { opacity: 0.25; }
    100% { opacity: 1; }
  }
  div {
    width: 80px;
    height: 80px;
    background: #1d4ed8;
    animation-name: slide, fade;
    animation-duration: 2s;
    animation-iteration-count: infinite;
  }
</style>

<div>Both</div>
Try It Yourself

How It Works

  1. Two rules. slide changes transform. fade changes opacity.
  2. List the names. animation-name: slide, fade runs both, in that order. A space without a comma is invalid and drops the declaration.
  3. One duration covers both. A single 2s is repeated for every name that does not have its own time.
  4. They share the element. Move and fade run together. One does not replace the other.

Edge Cases & Pitfalls

If the box sits still, one of these is usually why.

case

The name must match exactly

Slide does not match @keyframes slide. A typo still occupies a slot in a list, so the next duration stays paired with the wrong name.

0s

A name with no duration looks idle

animation-duration starts at 0s. The keyframes run, then finish before you can see them. Set a duration above zero.

short

The shorthand can clear the name

animation: 1s linear omits the name, so animation-name resets to none. Put the name in the shorthand, or set animation-name after it.

list

Shorter lists repeat

One name and two durations run that animation twice. Two names and one duration give both names the same duration. none in the middle of a list disables that slot only.

motion

Some people need less motion

A looping animation can be hard to read. prefers-reduced-motion is how a visitor asks for less motion. Offer a still state when that query matches.

Browser Support

animation-name is a browser animation property. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Since Sep 2015

animation-name

Unprefixed: Chrome 43+, Firefox 16+, Safari 9+, Edge 12+, Opera 30+. Internet Explorer 10+. Samsung Internet 4+.

98% Unprefixed support
Google Chrome 43+ · 3+ with -webkit-
Full support
Mozilla Firefox 16+ · 5+ with -moz-
Full support
Apple Safari 9+ · 4+ with -webkit-
Full support
Microsoft Edge 12+
Full support
Opera 30+ · 15+ with -webkit-
Full support
Samsung Internet 4+
Full support
Internet Explorer 10+
Full support
animation-name Widely supported

Bottom line: Safe unprefixed in current browsers. Safari 4–8, Chrome 3–42, and Firefox 5–15 needed a prefix on both animation-name and @keyframes. Internet Explorer 10 supports the property and plain names. Quoted names are for current browsers.

Key Takeaways

  • Role: choose the @keyframes rule. The name does not describe the motion by itself.
  • Match: same spelling and same case as @keyframes. none means no keyframes.
  • Duration: set animation-duration above 0s or the name looks idle.
  • Lists: commas run several animations. A shorter timing list repeats. The property is not inherited.

One line: animation-name only picks the @keyframes rule. Pair it with a duration, or the box will not appear to move.

Frequently Asked Questions

It chooses which @keyframes rule an element runs. The name must match the keyframes name exactly, including letter case. If nothing matches, nothing animates.
The initial value is none. No keyframes run until you set a name. The property is not inherited.
The usual cause is animation-duration. Its default is 0s, so the animation finishes before you can see it. A mismatched or differently cased name also runs nothing.
Yes. Separate names with commas, such as slide, fade. Other animation properties pair with those names in the same order. A shorter list is repeated until every name has a value.
Yes. The name is one value in the animation shorthand. If you omit it, the shorthand resets animation-name to none and the animation does not run.
Unprefixed support is Chrome 43+, Firefox 16+, Safari 9+, Edge 12+, and Opera 30+. Internet Explorer 10 and Samsung Internet 4 also support it. It is a browser property. Node.js, Deno, and Bun do not apply it.

Next: animation-play-state

Pause or resume an animation that already has a name.

animation-play-state 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