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.

New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources