CSS animation-play-state
Anonymous contributor
Published Jul 8, 2021Updated Nov 23, 2024
Contribute to Docs
Defines whether an animation is running or paused.
Syntax
animation-play-state: <value>;
where <value> can be one of the following:
paused: the animation is paused.running: the animation is running.
Example 1
Set animation state to running:
div {height: 200px;width: 200px;background-color: blue;animation-name: disappear;animation-duration: 2s;animation-play-state: running;}@keyframes disappear {from {background-color: blue;}to {background-color: white;}}
The output will look like this:

Example 2
Pause the animation on div click:
div {height: 200px;width: 200px;background-color: blue;animation-name: disappear;animation-duration: 4s;animation-play-state: running;}@keyframes disappear {from {background-color: blue;}to {background-color: white;}}
// Target divconst box = document.querySelector('div');// Pause transition on clickbox.addEventListener('click', () => {box.style.animationPlayState = 'paused';});
The output will look like this:

Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn CSS on Codecademy
- Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
- Includes 34 Courses
- With Professional Certification
- Beginner Friendly.115 hours
- A full-stack engineer can get a project done from start to finish, back-end to front-end.
- Includes 51 Courses
- With Professional Certification
- Beginner Friendly.150 hours