steps() CSS function

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

The steps() CSS function defines a transition that divides the input time into a specified number of intervals that are equal in length. This subclass of step functions are sometimes also called staircase functions.

Syntax

css
/* Different intervals */
steps(2, end)
steps(4, jump-end)
steps(12, end)

/* Different jump positions */
steps(3, jump-start)
steps(3, jump-end)
steps(3, jump-none)
steps(3, jump-both)

Parameters

The function accepts the following parameters:

<integer>

Represents the number of equidistant intervals or 'steps'. It must be a positive integer greater than 0 unless the second parameter is jump-none, in which case, it must be a positive integer greater than 1.

<step-position>

Specifies when the jump between values occurs. If omitted, it defaults to end. The possible keyword values include:

jump-start or start

Indicates that the first step happens when the animation begins.

jump-end or end

Indicates that the last step happens when the animation ends.

jump-none

Indicates neither early nor late jumps happen.

jump-both

Indicates both early and late jumps happen.

Description

The steps() function divides the animation duration into equal intervals. For example, steps(4, end) divides the animation into four equal intervals, with values changing at the end of each interval except the last change which occurs at the animation's end.

If an animation contains multiple segments, the specified number of steps applies to each segment. For example, if an animation has three segments and uses steps(2), there will be six steps in total, with two steps per segment.

The following image shows the affect of different <step-position> values when the jumps occur:

css
steps(2, jump-start)  /* Or steps(2, start) */
steps(4, jump-end)    /* Or steps(4, end) */
steps(5, jump-none)
steps(3, jump-both)

Graphs of Input progress to Output progress, of which steps(2, jump-start) shows horizontal lines extending 0.5 unit from (0, 0.5) and (0.5, 1), respectively, with empty circles at the origin and (0.5, 0.5); steps(4, jump-end) shows horizontal lines extending 0.25 unit from (0, 0), (0.25, 0.25), (0.5, 0.5), and (0.75, 0.75), respectively, with unfilled circles at (0.25, 0), (0.5, 0.25), and (0.75, 0.5), and a solid circle at (1, 1); steps(5, jump-none) shows horizontal lines extending 0.2 unit from (0, 0), (0.2, 0.25), (0.4, 0.5), (0.6, 0.75), and (0.8, 1), respectively, with unfilled circles at (0.2, 0), (0.4, 0.25), (0.6, 0.5), and (0.8, 0.75); steps(3, jump-both) shows horizontal lines extending 1/3 unit from (0, 0.25), (1/3, 0.5), and (2/3, 0.75),respectively , with a solid circle at (1, 1) and unfilled circles at the origin, (1/3, 0.25), (2/3, 0.5), and (1, 0.75).

Formal syntax

<steps()> = 
steps( <integer> , <step-position>? )

<integer> =
<number-token>

<step-position> =
jump-start |
jump-end |
jump-none |
jump-both |
start |
end

Examples

Using the steps() function

The following steps() functions are valid:

css
/* Five steps with jump at the end */
steps(5, end)

/* Two steps with jump at the start */
steps(2, start)

/* Using default second parameter */
steps(2)

The following steps() functions are invalid:

css
/* First parameter must be an <integer>, not a real value */
steps(2.0, jump-end)

/* Number of steps must be positive */
steps(-3, start)

/* Number of steps must be at least 1 */
steps(0, jump-none)

Specifications

Specification
CSS Easing Functions Level 1
# step-easing-functions

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
steps() with start, end or no direction
Chrome – Full support
Chrome 8 (Release date: 2010-12-02)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Full support
Firefox 4 (Release date: 2011-03-22)
footnote Full support
Opera – Full support
Opera 12.1 (Release date: 2012-11-20)
footnote Full support
Safari – Full support
Safari 5.1 (Release date: 2011-07-20)
footnote Full support
Chrome Android – Full support
Chrome Android 18 (Release date: 2012-06-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 4 (Release date: 2011-03-29)
footnote Full support
Opera Android – Full support
Opera Android 14 (Release date: 2013-05-21)
footnote Full support
Safari on iOS – Full support
Safari on iOS 5 (Release date: 2011-10-12)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1 (Release date: 2013-04-27)
footnote Full support
WebView Android – Full support
WebView Android 4 (Release date: 2011-10-18)
footnote Full support
WebView on iOS – Full support
WebView on iOS 5 (Release date: 2011-10-12)
footnote Full support
jump- keywords for steps()
Chrome – Full support
Chrome 77 (Release date: 2019-09-10)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 65 (Release date: 2019-01-29)
footnote Full support
Opera – Full support
Opera 64 (Release date: 2019-10-07)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Chrome Android – Full support
Chrome Android 77 (Release date: 2019-09-10)
footnote Full support
Firefox for Android – Full support
Firefox for Android 65 (Release date: 2019-01-29)
footnote Full support
Opera Android – Full support
Opera Android 55 (Release date: 2019-12-03)
footnote Full support
Safari on iOS – Full support
Safari on iOS 14 (Release date: 2020-09-16)
footnote Full support
Samsung Internet – Full support
Samsung Internet 12 (Release date: 2020-06-19)
footnote Full support
WebView Android – Full support
WebView Android 77 (Release date: 2019-09-10)
footnote Full support
WebView on iOS – Full support
WebView on iOS 14 (Release date: 2020-09-16)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also