Set how many times an Animation should run with CSS

Use the animation-iteration-count property to set how many times the animation should run with CSS.

The following example sets the count of animation to 2:


Live Demo

<!DOCTYPE html>
         div {
            width: 150px;
            height: 200px;
            background-color: yellow;
            animation-name: myanim;
            animation-duration: 2s;
            animation-iteration-count: 2;
         @keyframes myanim {
         from {
            background-color: green;
         to {
               background-color: blue;

      <div> </div>