You want an animation to play, rest for a few seconds, and play again — a glitch that fires now and then, a logo that wiggles every 5 seconds. The obvious animation-delay does not do it: it waits once, before the first run, and then the loop repeats back to back. Here are three ways to get a real delay between iterations of a CSS animation, from the classic trick to a pause you can change with one variable. Every example has a live demo right on the page, so you can watch the difference before you copy the code.
The quick answer
Make the pause part of the animation. Set the duration to motion + pause, finish the motion early in the keyframes and hold still until 100%:
.ping {
/* 0.6 s of motion + 2 s of rest = 2.6 s */
animation: ping 2.6s ease-out infinite;
}
@keyframes ping {
0% { transform: translateX(0); }
6% { transform: translateX(14px); }
12% { transform: translateX(-8px); }
18% { transform: translateX(4px); }
23%, 100% { transform: translateX(0); } /* 0.6 / 2.6 ≈ 23% */
}
Live example — the same 0.6 s jitter, without and with a pause:
That works everywhere. Its weak spot: the pause is baked into the percentages. The second way below fixes that.
Why animation-delay does not repeat
animation-delay is applied once, when the animation starts. After that, infinite plays iteration after iteration with no gap. There is no animation-iteration-delay property in CSS.
Way 1: hold the last keyframe
The duration becomes the whole cycle: motion plus rest. Squeeze the motion into the first part of the keyframes and repeat the end state up to 100%.
The math: motion ÷ (motion + pause). For 0.6 s of motion and 2 s of rest, the motion ends at 0.6 / 2.6 ≈ 23%.
Good for one fixed rhythm. But change the pause from 2 s to 4 s and every percentage has to be recalculated, and two elements with different pauses need two copies of the keyframes. Keyframe selectors cannot use var(), so a variable will not help here.
Way 2: a clock on @property, the pause in a variable
This is the trick every effect on this site uses. Instead of animating the motion directly, animate one number — a clock --t that runs from 0 to 1 once per cycle. Then compute the motion from the clock with calc().
@property --t {
syntax: "<number>";
inherits: true;
initial-value: 0;
}
@keyframes clock {
to { --t: 1; }
}
.ping {
--run: 0.6; /* seconds of motion */
--pause: 2; /* seconds of rest */
animation: clock calc((var(--run) + var(--pause)) * 1s) linear infinite;
/* progress of the motion: 0 → 1, then it stays 1 for the pause */
--p: clamp(0, var(--t) * (var(--run) + var(--pause)) / var(--run), 1);
/* a damped swing: two back-and-forths that lose strength */
transform: translateX(calc(16px * (1 - var(--p)) * sin(var(--p) * 720deg)));
}
Why it works, step by step:
@propertyregisters--tas a number. A normal custom property cannot be animated — it jumps. A registered one is interpolated frame by frame.- The clock takes run + pause seconds and runs
linear, so--tis simply "where we are in the cycle". --pstretches the first part of the cycle to 0 → 1 andclamp()holds it at 1 for the rest. That is the pause — computed, not typed into keyframes.- The motion is any formula of
--p. Heresin()makes the swing and(1 - p)fades it out, so it settles smoothly instead of stopping dead.
Now one rule serves any rhythm. Set the pause per element — no new keyframes:
The same clock drives the real effects here. In Chromatic Wave it swings the red and blue copies of the word, then rests for --gw-pause:
Glitch Text uses it to open short "tear windows" inside the cycle, and Glitch Image starts the clock on :hover, so the photo glitches, calms down, and glitches again while the cursor stays on it. In Typewriter one clock runs the whole cycle — type, hold, erase, pause.
Way 3: JavaScript, when the pause should be random
A fixed rhythm starts to feel mechanical. A broken neon tube does not blink every 4 seconds — it blinks about every 4 seconds. CSS has no random numbers yet, so here a few lines of JS are the honest tool:
const sign = document.querySelector(".sign");
function flicker() {
sign.classList.remove("is-flickering");
void sign.offsetWidth; // restart the CSS animation
sign.classList.add("is-flickering");
// next one in 4 s ± 40%
setTimeout(flicker, 4000 * (0.6 + Math.random() * 0.8));
}
setTimeout(flicker, 4000);
The animation itself stays in CSS (one run, no infinite); JS only decides when. Keep the base pause in a CSS variable and read it with getComputedStyle(sign).getPropertyValue("--pause"), so designers still tune it in the stylesheet. That is how Neon Sign picks a random letter and a random moment:
Which one to use
| You need | Use |
|---|---|
| One element, fixed rhythm, oldest browsers | Way 1: hold keyframes |
| Pause as a setting, many elements, smooth motion | Way 2: @property clock |
| Random or event-driven pauses | Way 3: a few lines of JS |
Gotchas
- Browser support.
@propertyworks in Chrome and Edge 85+, Safari 16.4+ and Firefox 128+;sin()in all current browsers. Without@propertythe clock does not move,--pstays 0 and the element simply stands still — a safe fallback. inherits: truematters when pseudo-elements or children read the clock (::before,::after). Withfalsethey see only the initial value.- Animate
transformandopacity. The clock itself is cheap, but whatever you compute from it is repainted every frame — avoidwidth,topor bigbox-shadowthere. - Easing lives in the formula. The clock must run
linear; shape the motion withsin(), a power (var(--p) * var(--p)) orclamp()windows. - Way 1 with
ease-outapplies the easing between each pair of keyframes, not to the whole cycle. If the motion looks mushy, setanimation-timing-functioninside the keyframes.
Accessibility
A pause already makes motion calmer, but people who turn on "reduce motion" should get none:
@media (prefers-reduced-motion: reduce) {
.ping { animation: none; }
}
With the clock, animation: none leaves --t at 0, so the element rests in its start pose. Effects on this site show a "Play anyway" button instead of forcing motion.
FAQ
How do I add a delay between iterations of a CSS animation?
Include the delay in the animation duration and keep the last keyframe until 100% (Way 1), or animate an @property clock and compute a pause with clamp() (Way 2). animation-delay alone only delays the first iteration.
Is there an animation-iteration-delay property?
No. CSS has animation-delay (once, before the first run) and animation-iteration-count (how many runs), but nothing for the gap between runs. With animation-iteration-count: infinite the rest has to live inside the cycle — hold keyframes or a clock, as above.
Can I see a live example of a CSS animation with a pause?
Yes — every demo on this page is live, and the effect cards above show the same trick in finished effects. On each effect page the pause is a setting: change it and watch the rhythm change, then copy the code.
Can I pause an animation with animation-play-state?
animation-play-state: paused freezes an animation where it is, for example on :hover. It is a pause button, not a rhythm: it does not add rest between loops by itself.
How do I make the pause random?
CSS cannot pick random numbers yet, so use a short setTimeout loop that restarts the animation (Way 3). For a pseudo-random look without JS, give several elements clocks with different, unrelated pauses — like 1.3 s, 2.1 s and 3.4 s — so they never sync up.
Does this work for transitions?
Transitions run once per state change, so there is nothing to repeat. transition-delay delays the start of each change; for a looping rest use an animation.