animation-play-state
Example
.marquee:hover {
animation: none;
}.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: noneto pause, so the element jumps back to the start.
Key points
- Pausing uses
animation-play-state: pausedinstead 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.