👀 Live Preview
Number field with min="1" max="10" step="2"—use the spinner to see 1, 3, 5, 7, 9:
Try typing 2 or 4—the browser marks them invalid on submit.

The step attribute is used on <input> elements to specify the legal increment (or decrement) between allowed values. It works with numeric and date/time input types such as number, range, date, datetime-local, time, month, and week.
When users click the spinner arrows on a number field or drag a range slider, the browser jumps by the step amount. Form validation also rejects values that do not fit the step rule.
number, range.
Spinner steps.
Valid values.
Any decimal.
Seconds unit.
input.step.
stepThe primary purpose of the step attribute is to set stepping constraints for numeric, date, and time input fields. It defines how much the value should increase or decrease when users interact with spinners, sliders, or keyboard arrows.
By using step, you create more user-friendly forms and ensure that submitted data falls within meaningful increments—such as quantities sold in pairs, prices in half-dollar steps, or appointment times every 15 minutes.
Allowed values are not always multiples of step alone. The rule is min + n × step. With min="1" and step="2", valid values are 1, 3, 5, 7… (not even numbers).
Add step to a supported <input> type:
<label for="quantity">Quantity:</label>
<input
type="number"
id="quantity"
name="quantity"
min="1"
max="10"
step="2">number, range, date, datetime-local, time, month, and week inputs.number and range: 1 (or 1 if min is an integer).step="any" on number allows any decimal (no fixed increment).step is measured in seconds (e.g. 900 = 15 minutes).min and max for a complete valid range.HTMLInputElement.step.The step attribute accepts values based on the input type:
number input — A positive number or any. Example: step="2" jumps by 2 from min; step="0.01" for cents.range input — Defines slider tick increments. Example: step="5" with min="0" max="100" gives 0, 5, 10, … 100.date, datetime-local, and time — Interval in seconds. Example: step="86400" on date = one day; step="900" on time = 15 minutes.month and week — Also use seconds-based steps per HTML specification defaults.<!-- Number: increments of 2 from min 1 -->
<input type="number" min="1" max="10" step="2">
<!-- Range: slider moves in steps of 5 -->
<input type="range" min="0" max="100" step="5" value="50">
<!-- Time: 15-minute intervals -->
<input type="time" step="900">On a number field with min="1" and step="2", spinner clicks produce 1, 3, 5, 7, 9. Values like 2 or 4 fail constraint validation when the form is submitted.
| Topic | Detail | Example |
|---|---|---|
| Element | <input> | Form control |
| Types | number, range, date/time | type="number" |
| Default | 1 (number/range) | Omit attribute |
| Any decimal | step="any" | Prices, measurements |
| Validation | min + n × step | Constraint API |
| JavaScript | input.step | Dynamic updates |
| Input type | step supported? | Notes |
|---|---|---|
number | Yes | Number or any |
range | Yes | Slider increments |
date, time | Yes | Value in seconds |
datetime-local, month, week | Yes | Seconds-based step |
text, email, checkbox | No | Attribute ignored |
step vs min/max vs pattern| Attribute | Role | Example |
|---|---|---|
min / max | Lower and upper bounds | min="0" max="100" |
step | Increment between allowed values | step="5" |
pattern | Regex on text inputs | Not for number types |
step="any" | Disable increment rule | Free-form decimals |
Number input with fixed step, range slider, dynamic JavaScript step, and time picker intervals.
Number field with min="1" max="10" step="2"—use the spinner to see 1, 3, 5, 7, 9:
Try typing 2 or 4—the browser marks them invalid on submit.
Quantity field that accepts values in steps of 2 from 1:
<label for="quantity">Quantity:</label>
<input
type="number"
id="quantity"
name="quantity"
min="1"
max="10"
step="2">With step="2" and min="1", the spinner moves 1 → 3 → 5 → 7 → 9. This is not the same as “even numbers only”—the starting min value matters.
Slider that moves in increments of 5:
<label for="volume">Volume:</label>
<input
type="range"
id="volume"
min="0"
max="100"
step="5"
value="50">Dragging the slider snaps to 0, 5, 10, 15, … up to 100. Smoother UX for settings like volume or brightness.
Change the step at runtime when requirements change:
<label for="dynamicStepField">Enter a number:</label>
<input type="number" id="dynamicStepField">
<script>
document.getElementById("dynamicStepField").step = "0.5";
</script>In this script, step is set to 0.5 for the input with id dynamicStepField. Useful when toggling between whole units and half units based on user choice.
<label for="..."> so users know what the step-controlled field represents.aria-valuetext for custom formatting.On input.
Spinner/slider.
min + n×step.
Valid increments.
The step attribute is supported on relevant input types in all modern browsers. Date/time step behavior is consistent in current Chrome, Firefox, Safari, and Edge.
number, range, and date/time types honor step for UI and validation.
Bottom line: Use step confidently on supported input types in production forms.
step to guide users toward accurate, valid inputmin and max for a complete rangestep="any" when decimals must be free-formstep="2" always means even numbers (check min)step to unsupported input typesThe step attribute is a powerful tool for fine-tuning user input in numeric, range, and date/time fields in HTML forms. By leveraging it with min and max, you improve precision and usability.
Whether you need whole-number quantities, half-unit measurements, or scheduled time slots, step gives browsers a clear rule for spinners, sliders, and validation.
stepBookmark these when building form controls.
Spinner steps
Purposenumber, range
ScopeValid set
RuleJavaScript
DynamicAll browsers
Supportinput types. Spinners and validation use this value.number, range, date, datetime-local, time, month, and week.min + n × step. With min="1" and step="2", you get 1, 3, 5, 7…number inputs, it allows any decimal value without enforcing a fixed increment.input.step, for example input.step = "0.5".step is in seconds. step="900" limits selection to 15-minute intervals.Try the quantity field and use the spinner to see how step="2" behaves with min="1".
5 people found this page helpful