CSS Countdown Animation: Numbers and Ring Timers
A pure CSS countdown animates a registered integer custom property from the start number to zero and prints it with a counter. Register --n with @property as an integer, animate it with steps() so it ticks once a second, and show it with counter-reset: n var(--n) and content: counter(n). A ring adds an animated stroke-dashoffset.
| Piece | CSS | Job |
|---|---|---|
| Typed variable | @property --n { syntax: "<integer>" } | Lets the browser animate the number |
| Ticking | animation: count 3s steps(3) forwards | One jump per second, holds the last value |
| Printing | counter-reset: n var(--n) | Turns the variable into a counter |
| Showing | ::after { content: counter(n) } | Draws the current number |
| Ring | stroke-dashoffset: 0 to circumference | Empties a circle over the same time |
Updated
A splash countdown, a quiz timer or a launch moment does not need a script. This page builds a 3-2-1 number countdown and a ring countdown with CSS alone, lets you generate one with your own start number and speed, and gives a fallback for older browsers. For a countdown to a calendar date, use our countdown timer generator instead.
Countdown generator
<style>
@property --n { syntax: "<integer>"; inherits: false; initial-value: 0; }
.countdown { position: relative; width: 120px; height: 120px; display: grid; place-items: center;
font: 700 48px system-ui; color: #0f172a }
.countdown .num { animation: count 3s steps(3) forwards; counter-reset: n var(--n) }
.countdown .num::after { content: counter(n) }
@keyframes count { from { --n: 3 } to { --n: 0 } }
.ring { position: absolute; inset: 0; transform: rotate(-90deg) }
.ring circle { fill: none; stroke-width: 8 }
.ring .track { stroke: #e2e8f0 }
.ring .bar { stroke: #4F98FB; stroke-linecap: round; stroke-dasharray: 283;
animation: empty 3s linear forwards }
@keyframes empty { to { stroke-dashoffset: 283 } }
@media (prefers-reduced-motion: reduce) { .ring .bar { animation: none } }
</style>
<div class="countdown" role="timer" aria-label="Countdown from 3">
<svg class="ring" viewBox="0 0 100 100" aria-hidden="true"><circle class="track" cx="50" cy="50" r="45"/><circle class="bar" cx="50" cy="50" r="45"/></svg>
<span class="num"></span>
</div>3-2-1 number countdown
Ticking number with @property and a counter
Edit the code to rerun it. The number drops once a second and stays at 0.
<style>
@property --n { syntax: "<integer>"; inherits: false; initial-value: 0; }
.countdown { position: relative; width: 120px; height: 120px; display: grid; place-items: center;
font: 700 48px system-ui; color: #0f172a }
.countdown .num { animation: count 3s steps(3) forwards; counter-reset: n var(--n) }
.countdown .num::after { content: counter(n) }
@keyframes count { from { --n: 3 } to { --n: 0 } }
</style>
<div class="countdown" role="timer" aria-label="Countdown from 3">
<span class="num"></span>
</div>Ring countdown
Number inside an emptying ring
The ring uses stroke-dashoffset on an SVG circle and stops moving when reduced motion is requested.
<style>
@property --n { syntax: "<integer>"; inherits: false; initial-value: 0; }
.countdown { position: relative; width: 120px; height: 120px; display: grid; place-items: center;
font: 700 48px system-ui; color: #0f172a }
.countdown .num { animation: count 5s steps(5) forwards; counter-reset: n var(--n) }
.countdown .num::after { content: counter(n) }
@keyframes count { from { --n: 5 } to { --n: 0 } }
.ring { position: absolute; inset: 0; transform: rotate(-90deg) }
.ring circle { fill: none; stroke-width: 8 }
.ring .track { stroke: #e2e8f0 }
.ring .bar { stroke: #4F98FB; stroke-linecap: round; stroke-dasharray: 283;
animation: empty 5s linear forwards }
@keyframes empty { to { stroke-dashoffset: 283 } }
@media (prefers-reduced-motion: reduce) { .ring .bar { animation: none } }
</style>
<div class="countdown" role="timer" aria-label="Countdown from 5">
<svg class="ring" viewBox="0 0 100 100" aria-hidden="true"><circle class="track" cx="50" cy="50" r="45"/><circle class="bar" cx="50" cy="50" r="45"/></svg>
<span class="num"></span>
</div>Fallback without @property
Stacked numbers with animation-delay
Each number is its own element and is shown for one second in turn. It works in any browser that supports CSS animations.
<style>
.stack { position: relative; width: 80px; height: 64px; font: 700 48px system-ui; text-align: center }
.stack span { position: absolute; inset: 0; opacity: 0; animation: show 1s steps(1) forwards }
.stack span:nth-child(2) { animation-delay: 1s }
.stack span:nth-child(3) { animation-name: stay; animation-delay: 2s }
@keyframes show { from { opacity: 1 } to { opacity: 0 } }
@keyframes stay { from, to { opacity: 1 } }
</style>
<div class="stack" role="timer"><span>3</span><span>2</span><span>1</span></div>
Why the counter trick works
Registering --n as an integer gives it a type, so keyframes from 3 to 0 produce in-between whole numbers instead of a sudden swap. counter-reset accepts that integer through var(), and counter() turns it into text in a pseudo-element.
steps(3) splits a three second animation into three equal jumps. Without it you get the same numbers, but timing follows the easing curve and the ticks feel uneven.
Drawing the ring
An SVG circle's outline can be drawn as one dash as long as the circumference, 2 times pi times the radius. Moving stroke-dashoffset from zero to that length slides the dash out of view, so the ring empties smoothly.
Rotate the SVG by minus 90 degrees so the ring starts emptying from the top, and set stroke-linecap: round for a softer end.
How it works
- Pick the start number and seconds per step in the generator.
- Choose the number style, the ring style or both, and press replay to watch it again.
- Copy the HTML and CSS. It runs with no JavaScript at all.
- Read the fallback section if you must support browsers without @property.
Tips
- Use steps(n) with n equal to the start number, so each second shows one whole number.
- Add forwards to the animation so the final value stays after it ends.
- Wrap the ring's movement in a reduced motion query, but keep the numbers, since they carry the information.
- A CSS countdown cannot trigger anything when it ends. If something must happen at zero, listen for the animationend event in JavaScript.
Frequently asked questions
Why does my countdown jump straight to zero?
The custom property is not registered. An unregistered custom property cannot be interpolated, so the browser flips from the first value to the last. Add an @property rule with syntax "<integer>", inherits and an initial-value.
Which browsers support @property?
MDN lists @property as Baseline 2024, newly available across current browsers since July 2024. In older browsers the number does not tick, which is why a stacked-number fallback is shown on this page.
How do I make the countdown show Go at the end?
Add a second element with the word, start it at opacity 0 and give it an animation that fades in with an animation-delay equal to the countdown length. Hide the number at the same moment.
Is this the same as a countdown to a date?
No. A date countdown needs the current time, which CSS cannot read, so it requires JavaScript. Our countdown timer generator builds that kind. This page is for short fixed countdowns like 3-2-1.
Related: Countdown timer generator (to a date), CSS animation generator, CSS variables guide, CSS transitions playground, prefers-reduced-motion guide.
Build your site free or see all free tools. On We.Inc you can build your site free, with no card and no trial needed to start. AI building is on paid plans from $19 a month.
More in Guides
- CSS Cursor: All Values, Custom Cursors and Opacity
- Flexbox and Grid Cheat Sheet
- CSS Frameworks Compared: The Same Card, Six Ways
- CSS Masks, Shapes and 3D Perspective
- CSS Media Queries, Tested Live on Your Device
- BEM and CSS Naming Conventions
- Parallax Scrolling in Pure CSS
- CSS position: Five Values, One Live Demo
Product
Who It's For
- For Agencies
- For Freelancers
- For Hosting Providers
- For SaaS Platforms
- For Startups
- For Financial Services
- For Healthcare
Features
Resources
- Blog
- Help Center
- Free Business Tools
- Free UI Components
- Website Templates
- Template Collections
- Website Examples
- Guides
- Comparisons
- Alternatives
- Best Lists
- Reviews
- Pricing Guides
- Use Cases
- Glossary & Guides
- Integrations
- Developers
- Benchmark
- Windows App