HTML | DOM Style animationPlayState Property
The HTML DOM Style animationPlayState Property is used to specify whether an animation is running or paused.
Syntax :
animation-play-state: running|paused|initial|inherit;
Property Values:
- running: This value is used to run/play an animation.
- paused: This value is used to pause an animation.
- initial: This value sets the animation-play-state property to the value of the parent element.
- inherit: This value is used to set the .animation-play-state property to default(running).
Example: animation-play-state: running
<!DOCTYPE html> <html> <head> <title> HTML | DOM Style animationPlayState Property </title> <style> div { height: 100px; width: 150px; font-size: 100px; -webkit-animation: movement 3s infinite; -webkit-animation-play-state: paused; animation: movement 3s infinite; color: darkgreen; position: relative; <!-- property value "running" --> animation-play-state: running; } @-webkit-keyframes movement { from { left: 50px; } to { left: 400px; } } @keyframes movement { from { left: 50px; } to { left: 400px; } } </style> </head> <body> <br> <div id="block">Geeks For Geeks</div> </body> </html> |
Output :
Example: animation-play-state : paused
<!DOCTYPE html> <html> <head> <title> HTML | DOM Style animationPlayState Property </title> <style> div { height: 100px; width: 150px; font-size: 100px; -webkit-animation: movement 3s infinite; -webkit-animation-play-state: paused; animation: movement 3s infinite; color: darkgreen; position: relative; <!-- property value "paused" --> animation-play-state: paused; } @-webkit-keyframes movement { from { left: 50px; } to { left: 400px; } } @keyframes movement { from { left: 50px; } to { left: 400px; } } </style> </head> <body> <button onclick="Play()"> Click to make the object move </button> <script> function Play() { document.getElementById("block" ).style.WebkitAnimationPlayState = "running"; document.getElementById("block" ).style.animationPlayState = "running"; } </script> <br> <div id="block">Geeks For Geeks</div> </body> </html> |
Output :
Example : animation-play-state : inherit
<!DOCTYPE html> <html> <head> <title> HTML | DOM Style animationPlayState Property </title> <style> div { height: 50px; width: 150px; font-size: 100px; -webkit-animation: movement 3s infinite; -webkit-animation-play-state: paused; animation: movement 3s infinite; color: darkgreen; position: relative; animation-play-state: running; } h4 { width: 150px; -webkit-animation: movement 3s infinite; -webkit-animation-play-state: paused; animation: movement 3s infinite; color: darkgreen; position: relative; <!-- property value "inherit" --> animation-play-state: inherit; } @-webkit-keyframes movement { from { left: 50px; } to { left: 400px; } } @keyframes movement { from { left: 50px; } to { left: 400px; } } </style> </head> <body> <br> <div id="block"> Gfg <h4> I'm inherited</h4> </div> </body> </html> |
Output:
Example : animation-play-state : initial
<!DOCTYPE html> <html> <head> <title> HTML | DOM Style animationPlayState Property </title> <style> div { height: 100px; width: 150px; font-size: 100px; -webkit-animation: movement 3s infinite; -webkit-animation-play-state: paused; animation: movement 3s infinite; color: darkgreen; position: relative; <!-- property value "initial" --> animation-play-state: initial; } @-webkit-keyframes movement { from { left: 50px; } to { left: 400px; } } @keyframes movement { from { left: 50px; } to { left: 400px; } } </style> </head> <body> <br> <div id="block">Geeks For Geeks</div> </body> </html> |
Output :
Supported Browsers: The browser supported by animation-play-state property are listed below:
- Chrome: 43.0(4.0 webkit)
- Firefox: 16.0
- Safari: 4.0 webkit
- Edge: 10.0
- Opera: 30.0(15.0 Webkit)
Recommended Posts:
- HTML | DOM Style top Property
- HTML | DOM Style right Property
- HTML | DOM Style order Property
- HTML | DOM Style minWidth Property
- HTML | DOM Style borderRadius Property
- HTML | DOM Style visibility Property
- HTML | DOM Style tableLayout Property
- HTML | DOM Style flexBasis Property
- HTML | DOM Style objectPosition Property
- HTML | DOM Style cursor Property
- HTML | DOM Style borderRightStyle Property
- HTML | DOM Style objectFit Property
- HTML | DOM Style flexDirection Property
- HTML | DOM Style borderBottomColor Property
- HTML | DOM Style filter Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



