CSS animation-iteration-count
Published Jul 1, 2021Updated May 15, 2024
Contribute to Docs
Defines how many times an animation runs.
Syntax
animation-iteration-count: <value>;
where <value> can be one of the following:
- Number value:
3,300 infinitewill run animation on endless loop
Note: providing one value will apply to all animation-name values. Additional comma separated values will apply correspondingly.
Example 1
Run animation fadeoutfadein two times:
div {height: 200px;width: 200px;background-color: blue;animation-duration: 2s;animation-name: fadeoutfadein;animation-iteration-count: 2;}@keyframes fadeoutfadein {0% {background-color: blue;}50% {background-color: white;}100% {background-color: blue;}}

Example 2
Run animation fadeoutfadein two times and slideleft one time:
div {height: 200px;width: 200px;background-color: blue;animation-duration: 4s, 4000ms;animation-name: fadeoutfadein, slideleft;animation-iteration-count: 1, 2;}@keyframes fadeoutfadein {0% {background-color: blue;}50% {background-color: white;}100% {background-color: blue;}}@keyframes slideleft {from {margin-left: 100%;}to {margin-left: 0%;}}

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