CSS Portal

CSS animation-iteration-count Property

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The animation-iteration-count property in CSS defines how many times an animation should play before stopping. By default, most animations execute once, but this property allows designers to repeat the animation multiple times or infinitely, creating a continuous visual effect. It is particularly useful for drawing attention to specific elements, providing subtle motion to interfaces, or enhancing user interactions without relying on JavaScript. When used thoughtfully, it can contribute to a more dynamic and engaging user experience, making static elements feel lively or responsive.

This property is closely tied to animation as it determines the repetition of the keyframes defined in the @keyframes rule. For example, an element could fade in and out twice or bounce endlessly, depending on the count specified. It is also commonly paired with animation-direction, which controls whether the animation alternates directions on each iteration, enabling a back-and-forth effect rather than a simple restart. Without the iteration count set, an animation may complete just once, potentially missing the intended impact of motion in the design.

Beyond simple repetition, the animation-iteration-count property plays a critical role in timing and synchronization. When multiple animations are applied to the same element, coordinating the number of iterations ensures that transitions feel smooth and intentional. For instance, combining it with animation-delay can create cascading effects or staggered sequences, where one animation starts after another completes a specified number of iterations. Proper use of this property allows designers to create complex, visually appealing animations while maintaining control over how long and how often each effect occurs, resulting in polished, professional user interfaces.

Definition

Initial value
1
Applies to
All elements, :before and :after pseudo elements
Inherited
No
Computed value
As specified
Animatable
No
JavaScript syntax
object.style.animationIterationCount

Interactive Demo

Syntax

animation-iteration-count: <single-animation-iteration-count> [ ',&' <single-animation-iteration-count> ]*

Values

<single-animation-iteration-count> = infinite | <number>
  • infiniteThe animation will repeat forever.
  • <number>The number of times the animation should repeat; this is 1 by default. Negative values are invalid. You may specify non-integer values to play part of an animation cycle (for example 0.5 will play half of the animation cycle).

Example

<div class="demo">
<div class="box repeat-1">1×</div>
<div class="box repeat-3">3×</div>
<div class="box infinite">∞</div>
</div>
.demo {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: linear-gradient(135deg, #f6f8ff, #eef6ff);
}

.box {
    width: 100px;
    height: 100px;
    background: linear-gradient(180deg, #4b6cb7, #182848);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
    font-weight: 700;
    box-shadow: 0 6px 18px rgba(24,40,72,0.15);
}

@keyframes bounce {
    0% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-28px);
    }
    100% {
        transform: translateY(0);
    }
}

/* Single iteration (default) */
.repeat-1 {
    animation: bounce 900ms cubic-bezier(.22,.8,.34,1);
    animation-iteration-count: 1;
}

/* Repeat three times */
.repeat-3 {
    animation: bounce 900ms cubic-bezier(.22,.8,.34,1);
    animation-iteration-count: 3;
}

/* Repeat forever */
.infinite {
    animation: bounce 900ms cubic-bezier(.22,.8,.34,1);
    animation-iteration-count: infinite;
}

Browser Support

The following information will show you the current browser support for the CSS animation-iteration-count property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 1st January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!