CSS animation-iteration-count property

The CSS animation-iteration-count property specifies the number of times an animation should be played. By default, animations run once, but you can control how many times they repeat.

Syntax

selector {
    animation-iteration-count: value;
}

Possible Values

Value Description
number Specifies how many times the animation should be played (e.g., 1, 2, 3)
infinite The animation will repeat forever

Example: Finite Iteration Count

The following example shows an animation that runs exactly 3 times −

<!DOCTYPE html>
<html>
<head>
<style>
    .box {
        width: 100px;
        height: 100px;
        background-color: #FF6B6B;
        position: relative;
        animation-name: slideAnimation;
        animation-duration: 2s;
        animation-iteration-count: 3;
    }
    
    @keyframes slideAnimation {
        from { left: 0px; }
        to { left: 200px; }
    }
</style>
</head>
<body>
    <div class="box"></div>
</body>
</html>
A red box slides from left to right 3 times, then stops at the starting position.

Example: Infinite Animation

The following example shows an animation that runs continuously −

<!DOCTYPE html>
<html>
<head>
<style>
    .infinite-box {
        width: 80px;
        height: 80px;
        background-color: #4ECDC4;
        border-radius: 50%;
        animation-name: pulse;
        animation-duration: 1s;
        animation-iteration-count: infinite;
    }
    
    @keyframes pulse {
        0% { transform: scale(1); }
        50% { transform: scale(1.2); }
        100% { transform: scale(1); }
    }
</style>
</head>
<body>
    <div class="infinite-box"></div>
</body>
</html>
A teal circle continuously pulses, growing larger and smaller in an endless loop.

Conclusion

The animation-iteration-count property gives you precise control over animation repetition. Use specific numbers for limited repetitions or infinite for continuous animations.

Updated on: 2026-03-15T12:43:04+05:30

103 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements