The
step
attribute is a number that specifies the granularity that the value must adhere to. Only values that match the specified stepping interval (
min
if specified,
value
otherwise, or an appropriate default value if neither of those is provided) are valid.
The
step
attribute can also be set to the
any
string value. This
step
value means that no stepping interval is implied and any value is allowed in the specified range (barring other constraints, such as
min
and
max
). See the
Setting step to the
any
value
example for how this works in supported browsers.
Note:
When the value entered by a user doesn't adhere to the stepping configuration, the
user agent
may round off the value to the nearest valid value, preferring to round numbers up when there are two equally close options.
The default stepping value for
range
inputs is 1, allowing only integers to be entered,
unless
the stepping base is not an integer; for example, if you set
min
to -10 and
value
to 1.5, then a
step
of 1 will allow only values such as 1.5, 2.5, 3.5,… in the positive direction and -0.5, -1.5, -2.5,… in the negative direction. See the
HTML
step
attribute
.