animation-name

Term side of the Card.
Topic: Animations
Unit title: animation-name
Categories: Property
Explanation side of the Card

Explanation: The property that specifies the name of the animation defined by `@keyframes`. It associates the keyframes with the element, indicating to the browser which animation to apply based on the sequence of styles.

Browser compatibility:
  • The chrome browser supports this feature starting from version 43.
  • The edge browser supports this feature starting from version 12.
  • The firefox browser supports this feature starting from version 16.
  • The safari browser supports this feature starting from version 9.
Availability: 

Example

Wrongcss
.badge {
  animation-name: Pop;
  animation-duration: 0.3s;
}
@keyframes pop {
  from { scale: 0.8; }
}
Rightcss
.badge {
  animation-name: pop;
  animation-duration: 0.3s;
}
@keyframes pop {
  from { scale: 0.8; }
}

Keyframe names are case-sensitive, so 'Pop' doesn't match @keyframes pop.

Common mistakes

  • A typo in the name makes the animation silently do nothing.
  • Two @keyframes rules share one name, and only the last one is used.

Key points

  • Every name matches a defined @keyframes rule exactly, including letter case.
  • Names are specific, like 'fade-in-up', so they don't collide with keyframes from other stylesheets.

Interview questions

What happens if animation-name doesn't match any @keyframes?

No animation runs and no error is shown, so the element keeps its normal styles.

Can I list several animation names?

Yes. Separate names with commas; the other animation longhands map to them by position.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy