Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Transforms, Transitions and Animations

The animation-play-state property

Reference for the CSS animation-play-state property: running and paused, how to pause on hover or with a checkbox, and what happens to timing when you resume.

The animation-play-state property pauses or resumes a CSS animation without restarting it. While paused, the element keeps the values it had at that moment. When you set it back to running, the animation continues from where it stopped.

It is the CSS-only way to build "pause on hover" or a play/pause toggle without any script.

CSS
.marquee:hover {
  animation-play-state: paused;
}

Try it

Pause with a checkbox

Syntax

CSS
animation-play-state: running | paused;

/* one value per animation name */
animation-play-state: running, paused;
  • Initial value: running
  • Applies to: all elements, ::before and ::after
  • Inherited: no
  • Animatable: no
  • Computed value: as specified

Values

Value Description
running The animation progresses normally.
paused The animation is frozen at its current progress. The element keeps the animated values from that moment.

Usage notes

  • Resuming continues, it does not restart. Time spent paused is not counted. A 10-second animation paused at 4 seconds resumes with 6 seconds to go.
  • Pause one of several animations. Provide a comma-separated list in the same order as the names: animation-play-state: running, paused;.
  • Put the rule on the element that has the animation. The property is not inherited. A :hover rule on a parent must target the animated child with a descendant selector, as in the example above.
  • Setting paused before the first frame starts the animation in a paused state at 0%, which lets a script or a checkbox start it later.
  • Delays keep counting only while running. A paused animation that is still in its delay stays in its delay.
  • Accessibility. Moving content that lasts more than five seconds and starts automatically should have a way to pause it. A :hover pause alone does not help keyboard users, so add :focus-within or a real button as well. Also honor prefers-reduced-motion.
  • Prefer the Web Animations API for complex control. If you need to seek, reverse or change speed, element.getAnimations() offers pause(), play() and playbackRate.

Browser support

Supported in every current browser. The :has() selector used in the example is also available in current browsers.