CSS steps() Function

The steps() function allows you to break an animation into a specific number of discrete frames.

Most CSS easing functions (like ease, linear, or cubic-bezier()) are designed to create smooth transitions by calculating hundreds of intermediate values between the start and end of an animation. The steps() function does the exact opposite.

Instead of a smooth glide, steps() divides the animation into equal segments and jumps instantly from one state to the next. If you've ever wanted to create a frame-by-frame sprite animation, a ticking second hand on a clock, or a retro typing effect, this is the function you need.

Here's a side-by-side comparison. Both boxes take exactly 3 seconds to cross the screen, but the second box uses steps(5) to break the journey into five distinct jumps:

View Output Full Screen Preview

Controlling the Jump Position

The steps() function accepts an optional second parameter that tells the browser when the jump should happen during each step interval. If you don't provide one, it defaults to jump-end.

A Real-World Example: The Typing Effect

One of the most popular tricks using the steps() function is creating a typewriter effect entirely in CSS. By animating the width of a text container from 0 to its full length, and setting the number of steps to match the exact number of characters in the text, you get a perfect letter-by-letter reveal.

Here's how it looks in action:

View Output Full Screen Preview

Official Syntax

The official syntax of the steps() function is as follows:

Where <step-position> is defined as:

Possible Values

As indicated in the official syntax, the steps() function accepts the following values:

integer

A positive integer representing the number of intervals (or frames) the animation should be broken into.

step-position

An optional keyword indicating when the jump occurs within the interval. It can be jump-start, jump-end, jump-none, jump-both, start, or end. If omitted, it defaults to jump-end (which behaves the same as end).

CSS Specifications

Browser Support

The following table provided by Caniuse.com shows the level of browser support for this feature.