CSS Portal

CSS animation-name Property

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
animation-name
CSS PropertyThis property is supported by all modern browsers.
Updated 1st January 2026

Description

The animation-name property in CSS is a fundamental part of defining animations for HTML elements. It allows you to assign one or more keyframe animations to an element by referencing the names of the @keyframes rules defined elsewhere in your stylesheet. By specifying an animation name, you essentially tell the browser which set of keyframes should be applied to the element, giving you full control over how the element changes over time. Without this property, even if other animation-related properties like animation-duration or animation-timing-function are set, no visual transformation would occur because the browser would not know which keyframes to execute.

Using animation-name allows for modularity and reusability in CSS animations. You can define multiple keyframe sequences with different names and then apply them selectively to different elements by assigning the corresponding animation names. This approach promotes cleaner code and reduces repetition, especially when multiple elements share similar animation behaviors. For instance, you might have a keyframe animation called "fadeIn" for making elements gradually appear and another called "slideUp" for vertical movement. Applying these animations only requires referencing their names in animation-name, making it easy to manage complex animations across a site.

Additionally, animation-name works in combination with several other animation properties to create dynamic effects. Properties like animation-duration, animation-delay, and animation-iteration-count determine the timing, repetition, and sequencing of the named keyframes, allowing designers to fine-tune the behavior of animations. The separation of the animation definition (via @keyframes) and its application (via animation-name) provides flexibility, making it possible to apply the same animation to multiple elements with different durations, delays, or directions, resulting in visually appealing and efficient animations.

Definition

Initial value
none
Applies to
All elements, :before and :after pseudo elements
Inherited
No
Computed value
As specified
Animatable
No
JavaScript syntax
object.style.animationName

Interactive Demo

Syntax

animation-name: <single-animation-name> [ ',' <single-animation-name> ]* 

Values

<single-animation-name> = none | <IDENT>
  • noneIs a special keyword denoting no keyframes. It can be used to deactivate an animation without changing the ordering of the other identifiers, or to deactivate animations coming from the cascade.
  • <IDENT>A string identifying the animation. This identifier is composed by a combination of case-insensitive letters a to z, numbers 0 to 9, underscores (_), and/or dashes (-). The first non-dash character must be a letter (that is, no number at the beginning of it, even if preceded by a dash.) Also, two dashes are forbidden at the beginning of the identifier.

Example

<div class='container'>
<div class='box'></div>
<p class='label'>Example: animation-name</p>
</div>
.container {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 20px;
  background: #f0f4f8;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
}

.box {
  width: 120px;
  height: 120px;
  background: linear-gradient(135deg, #ff7a18, #af002d);
  border-radius: 12px;
  /* animation-name property specifies which @keyframes to use */
  animation-name: slide-and-rotate;
  animation-duration: 3s;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-direction: alternate;
}

@keyframes slide-and-rotate {
  0% {
    transform: translateX(0) rotate(0deg);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  }
  50% {
    transform: translateX(160px) rotate(180deg);
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.18);
  }
  100% {
    transform: translateX(320px) rotate(360deg);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  }
}
Open in editor

Browser Support

The following information will show you the current browser support for the CSS animation-name property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee