CSS animation-play-state Property

The animation-play-state property specifies whether a CSS keyframe animation is running or paused.

Pausing an animation freezes it at its current position. When playback resumes, the animation continues from where it stopped rather than restarting. This makes the property useful for interactive effects, hover controls, and animations that should temporarily stop.

animation-play-state Syntax

selector {
  animation-play-state: paused;
}

The property accepts two keyword values: running and paused.

.playing {
  animation-play-state: running;
}
.stopped {
  animation-play-state: paused;
}

For multiple animations, specify a comma-separated list of play states.

.multiple {
  animation-play-state: running, paused;
}

The property also accepts the global CSS values inherit, initial, revert, revert-layer, and unset.

Property Values

Value Description
running Allows the animation to progress normally. This is the initial value.
paused Pauses the animation at its current progress until playback resumes.
running, paused Allows the first animation to run while pausing the second animation.

The property applies to all elements, including the ::before and ::after pseudo-elements. It is not inherited and has an initial value of running.

Its computed value is the specified list of play state keywords. The animation-play-state property itself is not animatable.

How animation-play-state Works

CSS keyframe animations progress according to their timeline, duration, timing function, and iteration count. The animation-play-state property controls whether that progress continues or is temporarily suspended.

@keyframes slide {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(100px);
  }
}
.box {
  animation: slide 3s linear infinite alternate;
  animation-play-state: running;
}
.box.is-paused {
  animation-play-state: paused;
}

When the is-paused class is applied, the element stops at its current position. Removing the class restores running, allowing the animation to continue from that position.

Pausing an animation does not remove its keyframe effects. The element retains the appearance it had when playback stopped.

If an animation is paused during a positive delay, the remaining delay is also paused and continues when playback resumes.

Running and Paused Animations

Using running

The running value allows an animation to play according to its other animation settings.

.box {
  animation: slide 2s ease-in-out infinite alternate;
  animation-play-state: running;
}

Because running is the initial value, it does not need to be declared unless you are overriding another rule that pauses the animation.

Using paused

The paused value suspends playback without resetting the animation's progress.

.box {
  animation: slide 2s ease-in-out infinite alternate;
  animation-play-state: paused;
}

If the animation starts with paused, it remains at its initial animation progress until playback is enabled.

If the animation was already running, changing its play state to paused freezes it at the current position.

Setting the value back to running resumes the animation rather than starting a new iteration.

Pausing Animations on Hover

A common use of animation-play-state is to pause a continuously running animation when the user moves the pointer over an element.

.animated-icon {
  animation: spin 3s linear infinite;
}
.animated-icon:hover {
  animation-play-state: paused;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

The icon rotates continuously until the pointer moves over it. When the pointer leaves, the animation resumes from the same rotation angle.

You can also reverse the behavior by starting with a paused animation and running it on hover.

.animated-icon {
  animation: spin 3s linear infinite;
  animation-play-state: paused;
}
.animated-icon:hover,
.animated-icon:focus-visible {
  animation-play-state: running;
}

The second approach allows the animation to run only while the element is hovered or keyboard-focused, provided the element can receive focus.

For essential playback controls, provide an accessible button rather than relying exclusively on hover.

Multiple Animation Play States

When an element has several animations, you can pause one while allowing another to continue.

.animated-element {
  animation-name: move, fade;
  animation-duration: 2s, 3s;
  animation-iteration-count: infinite, infinite;
  animation-play-state: running, paused;
}

The move animation runs continuously, while the fade animation remains paused.

Play state values are matched to animations in the order specified by animation-name.

If fewer play state values are provided than animations, the browser repeats the list as needed.

.three-animations {
  animation-name: move, fade, rotate;
  animation-play-state: running, paused;
}

Here, move runs, fade is paused, and rotate runs.

This makes it possible to control different animation effects independently on the same element.

animation-play-state Example

The following example compares a running animation with one that starts paused. Hover over the running square to pause it, or hover over the paused square to resume it.

<div class="play-state-demo">
  <div class="play-state-row">
    <strong>running</strong>
    <div class="play-state-track">
      <div class="play-state-box running"></div>
    </div>
  </div>
  <div class="play-state-row">
    <strong>paused</strong>
    <div class="play-state-track">
      <div class="play-state-box paused"></div>
    </div>
  </div>
</div>
.play-state-demo {
  display: grid;
  gap: 12px;
}
.play-state-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.play-state-row strong {
  flex: 0 0 65px;
}
.play-state-track {
  flex: 1 1 140px;
  min-width: 0;
  height: 40px;
  padding: 5px;
  background-color: #f1f3f5;
  border: 1px solid #ccc;
  box-sizing: border-box;
}
.play-state-box {
  width: 30px;
  height: 28px;
  background-color: #1769aa;
  animation: play-state-move 3s linear infinite alternate;
}
.play-state-box.running {
  animation-play-state: running;
}
.play-state-box.paused {
  animation-play-state: paused;
}
.play-state-track:hover .running {
  animation-play-state: paused;
}
.play-state-track:hover .paused {
  animation-play-state: running;
}
@keyframes play-state-move {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(100px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .play-state-box {
    animation: none;
  }
}

The first square moves continuously until its track is hovered. The second square remains stationary until its track is hovered, then continues animating while the pointer stays over the track.

Browser Result
running
paused

Moving the pointer away restores each square's original play state. The animation continues from its paused position instead of restarting.

If reduced motion is enabled, both squares remain stationary.

Controlling Playback with JavaScript

JavaScript can change the animation-play-state property in response to a button click, allowing users to pause and resume animations without relying on hover.

The following example uses a button to toggle the animation's play state.

<button type="button" id="toggle-animation" aria-pressed="false">Pause Animation</button>
<div class="controlled-box"></div>
.controlled-box {
  width: 40px;
  height: 40px;
  background-color: #1769aa;
  animation: controlled-move 2s linear infinite alternate;
}
.controlled-box.is-paused {
  animation-play-state: paused;
}
@keyframes controlled-move {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(100px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .controlled-box {
    animation: none;
  }
}
const button = document.getElementById('toggle-animation');
const box = document.querySelector('.controlled-box');

button.addEventListener('click', () => {
  const paused = box.classList.toggle('is-paused');
  button.textContent = paused ? 'Resume Animation' : 'Pause Animation';
  button.setAttribute('aria-pressed', String(paused));
});

Clicking the button adds or removes the is-paused class. The button label and aria-pressed attribute update to reflect the selected pause state.

This approach works with mouse, keyboard, and touch input. It is useful when users need direct control over continuous animation.

Important Considerations

Keep the following points in mind when using animation-play-state:

  • Default value: The initial value is running, so animations play normally unless paused.
  • Resume behavior: A paused animation resumes from its previous progress rather than restarting.
  • Animation delays: Pausing during a delay also pauses the remaining delay time.
  • Multiple animations: Use comma-separated values to control the play state of each animation independently.
  • Completed animations: Setting running does not automatically restart an animation that has already finished.
  • Shorthand declarations: The animation shorthand can include play state, as in animation: slide 2s linear infinite paused;.
  • Hover controls: Hover-only controls are not available to every user. Provide keyboard-accessible controls when playback needs to be controlled directly.
  • Reduced motion: Respect prefers-reduced-motion and avoid unnecessary continuous animation.

Use animation-play-state when an animation should temporarily stop without losing its current progress.

Browser Support

The animation-play-state property has Baseline Widely available status and has been supported across major browser engines since September 2015, including Chrome, Edge, Firefox, and Safari.

Both running and paused are broadly supported. Older browser versions may require vendor-prefixed animation properties.

Visit Can I Use? to check current browser compatibility.

Specifications

The animation-play-state property is defined in the CSS Animations Level 1 specification.

CSS Animations Level 1