What is the step attribute in HTML?

Overview

In HTMLHypertext Markup Language, the step attribute is used to specify the legal step size of the <input> elements. The default value of stepping is 1.

For example, the possible legal values should be …,-2,0,2,4,… if the stepping value is 2.

This attribute is used with the following data types: number, date, month, time, week, and range.

Syntax


<input step = "value">

Parameters

This attribute takes value as its single argument.

Example

Explanation

In the above example, we set the value of step as 2. Due to this, it only shows the values which belong to step size 2.

Free Resources