Frontend Development 11 min read

Understanding CSS3 steps() Animation: Theory, Syntax, and Practical Examples

This article explains the CSS3 steps() timing function, contrasting it with linear animation, detailing its syntax, parameters, start/end behavior, and provides multiple practical demos—including frame-by-frame animations, typewriter effects, and countdown timers—while analyzing how steps divide animation segments and affect timing.

Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Understanding CSS3 steps() Animation: Theory, Syntax, and Practical Examples

CSS3 provides the animation property for smooth transitions, but the steps() timing function creates frame‑by‑frame (discrete) animations. Unlike linear interpolation, steps() jumps between defined points without intermediate states, making it suitable for sprite‑sheet effects.

The syntax is animation-timing-function: steps(number, [end|start]) , where number specifies how many intervals the animation is divided into. The optional second argument determines whether the jump occurs at the start or end of each interval; the default is end .

Parameter details:

number – a positive integer indicating the number of steps.

start or end – defines whether the jump happens at the beginning or the end of each step.

Example CSS:

animation-timing-function: steps(5, start);

To illustrate the effect, a series of demos use a 200×750px sprite with five color blocks. By animating background-position with steps(5, start) or steps(5, end) , the author shows how the first block disappears immediately with start , while end produces a smoother progression.

Further experiments modify animation duration, keyframe percentages, and additional properties like border . The results demonstrate that steps() partitions each CSS property’s keyframe changes into the specified number of segments, not the whole animation timeline.

Practical applications of steps() include:

Animating characters or animals using a long sprite sheet.

Creating a typewriter effect by revealing text frame by frame.

Implementing pure‑CSS countdown timers with counter-reset , @property , and steps() .

Replacing JavaScript delays with step-start or step-end animations.

Building hour‑minute‑second countdowns by animating digit sprites with steps(10,start) for seconds and steps(10,start) for minutes.

Each demo is linked to an online CodePen where the effect can be observed directly.

In conclusion, steps() offers a powerful way to create discrete animations without JavaScript, useful for sprite animations, typewriter effects, countdowns, and any scenario where precise frame control is needed.

frontendweb developmentcsssteps()
Rare Earth Juejin Tech Community
Written by

Rare Earth Juejin Tech Community

Juejin, a tech community that helps developers grow.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.