CSS propertyAnimations

animation-name

Specifies which @keyframes an element plays.

Initial value
none
Inherited
No
Animatable
no
Applies to
all elements and the ::before and ::after pseudo-elements
JavaScript
element.style.animationName = "slide"
On this page

Example

#
CSS
.badge {
  animation-name: pop;
  animation-duration: 0.6s;
}

@keyframes pop {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
Preview

Definition and usage

#

The animation-name property links an element to an animation defined in an @keyframes rule. The name alone is not enough: the animation only starts when it also has a duration (animation-duration) greater than zero.

You can provide several comma-separated names. Each animation then runs in parallel, and the other animation properties (duration, delay, iteration count) are matched to the names in the list in order.

If the name does not match any @keyframes rule, nothing happens and the browser reports no error. When an animation โ€œdoes not workโ€, check the spelling first.

Syntax

#
Syntax
animation-name: none | keyframes-name [, keyframes-name]*;

Values

#
  • none

    No animation. Useful for turning off an animation inherited from another rule.
  • slide

    keyframes-name

    The name of your own @keyframes rule. Here the element moves to the right and back.
  • pulse

    keyframes-name

    Another @keyframes rule: the element pulses and changes color.
  • slide, spin

    list of names

    Two animations at once. Both run in parallel and their transforms override each other, so the last one in the list wins.

Values in practice

#

none

No animation. Useful for turning off an animation inherited from another rule.
.demo .box { animation-name: none; }

slide

The name of your own @keyframes rule. Here the element moves to the right and back.
.demo .box { animation-name: slide; }

pulse

Another @keyframes rule: the element pulses and changes color.
.demo .box { animation-name: pulse; }

slide, spin

Two animations at once. Both run in parallel and their transforms override each other, so the last one in the list wins.
.demo .box { animation-name: slide, spin; }

Browser support

#

Widely available

Works in all modern browsers, phones included. You can use it without worry.

  • Chrome
  • Edge
  • Firefox
  • Safari

Good practices

#
  • Give keyframes descriptive names, such as fade-in or slide-up. They are easier to find in the stylesheet.
  • Respect the system setting that reduces motion: turn animations off or shorten them inside @media (prefers-reduced-motion: reduce).

Related entries

#

Spotted a mistake or missing an example? Write to us.