Home HTML Attributes step HTML step Attribute Definition
Definition and Usage The step attribute sets the granularity a value must follow — a positive number, or the keyword any. It applies to <input> types: number, range, date, month, week, time, and datetime-local.
It controls spinner ticks, range slider stops, and constraint validation (invalid values trigger stepMismatch). Pair with min and max . Defaults: 1 for number/range; 1 day/month/week or 60 seconds for date/time types.
Baseline · Widely available. Not deprecated. Stable form attribute across modern browsers (widely since about July 2015).
Step base matters. Valid values are whole steps from the base: min if set, else value, else 0 (week has a special default). Example: min="10" step="2" → 10, 12, 14…
Syntax
HTML Syntax <input step=" number | any " …>
The number must be positive (integer or float). any turns stepping off for validation (other limits still apply).
Values
Attribute Values Common patterns:
Value Description Try it 1 (default for number/range)Whole numbers from the step base Try it0.5 / 2Custom increments (decimals or every N) Try itanyNo step restriction Try itOn range / date-time Slider ticks or calendar/time units Try it
Try it
Live Preview Change step on a number input. Validity updates as you type or use the spinner.
Code
HTML Examples Short study snippets. Use Try It Yourself for a live editor.
1. Number + min 2. step=any 3. Range slider Example 1 — Even Numbers from 10 Step from a min base in increments of 2.
<label for="qty">Quantity (even, ≥ 10)</label>
<input id="qty" name="qty" type="number"
min="10" step="2" value="10"> How It Works min="10" is the step base.step="2" allows 10 + 2n only.Spinner jumps by 2 when supported.Validation rejects values that are not on that grid.Example 2 — Allow Any Decimal Use any when floats must be free (within min/max).
<label for="price">Price</label>
<input id="price" name="price" type="number"
min="0" step="any" placeholder="e.g. 4.25"> How It Works Default step is 1 for number — integers only unless you change it.step="any" removes the stepping rule.min/max still apply if present.Or set a fine step like 0.01 for currency-style grids.Example 3 — Range Slider Steps Control how far the thumb jumps on each move.
<label for="vol">Volume</label>
<input id="vol" name="vol" type="range"
min="0" max="100" step="10" value="50">
<output id="vol-out" for="vol">50</output> How It Works type="range" shows a slider.step="10" snaps to 0, 10, 20 … 100.min/max bound the track.output (optional) can display the live value for clarity. Edge Cases & Pitfalls Most bugs are a mismatched step base or forgetting the default of 1.
default Default step is 1 for number Decimals like 4.2 are invalid unless you set step="any", 0.1, or align min to that fraction.
base min shifts the valid grid min="1.2" step="2" allows 1.2, 3.2, 5.2… — not plain even integers from 0.
valid Off-step values are invalid They match :invalid / can set stepMismatch. Style and message accordingly.
a11y Explain the increment MDN: tell users the expected format (e.g. “even numbers from 10”) via the label or aria-describedby.
types Date/time units differ Defaults are days/months/weeks or 60 seconds for time — not always “1” in the same sense as number.
Compatibility
Browser Support step is an HTML attribute on numeric and date/time input types for increments and validation.
✓ Baseline · Widely available
step Widely available since about July 2015. Spinner/slider UI details vary by browser.
96% Global support (approx.)
Google Chrome All modern
Full support
Mozilla Firefox All modern
Full support
Apple Safari All modern
Full support
Microsoft Edge All modern
Full support
Opera All modern
Full support
Samsung Internet Modern
Full support
Internet Explorer 10+
Partial / older step Widely supported
Bottom line: Safe for modern forms. Always align min, step, and expected decimals — and say so in the label.
Remember
Key Takeaways Role: allowed value increment for numeric/date inputs.
Values: positive number or any.
Base: steps count from min (or value / 0).
Decimals: use any or a fractional step — default 1 rejects floats.
One line: step is the size of each valid jump from the step base.
Frequently Asked Questions What does the HTML step attribute do? step sets the allowed increment between valid values on numeric and date/time inputs. It affects spinners, range sliders, and constraint validation.
Which input types support step? number, range, date, month, week, time, and datetime-local. It is not used on text or email.
What is step=any? any means no stepping restriction — any value is allowed within other constraints such as min and max.
What is the default step? For number and range, default is 1. For date it is 1 day; for time and datetime-local it is 60 seconds; for month and week it is 1 unit of that type.
How does min affect step? Valid values are whole steps from the step base. The base is min if set, otherwise value, otherwise 0 (with a special default for week).
What happens if a value breaks the step? The control is invalid for constraint validation (stepMismatch) and can match :invalid / :out-of-range styling.
Next: style Continue with the HTML style attribute for inline CSS.
style tutorial → About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
8 people found this page helpful
Helpful Share Copy link Suggestion