animation-play-state

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

Explanation: The property that controls whether the animation is running or paused. It's useful for interactive elements where users control the animation.

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
.marquee:hover {
  animation: none;
}
Rightcss
.marquee:hover {
  animation-play-state: paused;
}

'paused' freezes the animation where it is, while animation: none removes it and resets the element.

Common mistakes

  • Setting animation: none to pause, so the element jumps back to the start.

Key points

  • Pausing uses animation-play-state: paused instead of removing the animation, which resets it.
  • Long or looping animations have a visible pause control, not only a hover state.

Interview questions

How do I pause a CSS animation from JavaScript?

Set element.style.animationPlayState = 'paused', or call pause() on an animation from element.getAnimations().

Does a paused animation resume from the same point?

Yes. Switching back to 'running' continues from where it was paused.

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