HTML step Attribute

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

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…

HTML Syntax

syntax.html
<input step=" number | any" …>

The number must be positive (integer or float). any turns stepping off for validation (other limits still apply).

Attribute Values

Common patterns:

ValueDescriptionTry it
1 (default for number/range)Whole numbers from the step baseTry it
0.5 / 2Custom increments (decimals or every N)Try it
anyNo step restrictionTry it
On range / date-timeSlider ticks or calendar/time unitsTry it

Live Preview

Change step on a number input. Validity updates as you type or use the spinner.

Demo uses min="0". With step 2, try 1 — it should be invalid.

Input

HTML Examples

Short study snippets. Use Try It Yourself for a live editor.

Example 1 — Even Numbers from 10

Step from a min base in increments of 2.

HTML
<label for="qty">Quantity (even, ≥ 10)</label>
<input id="qty" name="qty" type="number"
       min="10" step="2" value="10">
Try It Yourself

How It Works

  1. min="10" is the step base.
  2. step="2" allows 10 + 2n only.
  3. Spinner jumps by 2 when supported.
  4. Validation rejects values that are not on that grid.

Example 2 — Allow Any Decimal

Use any when floats must be free (within min/max).

HTML
<label for="price">Price</label>
<input id="price" name="price" type="number"
       min="0" step="any" placeholder="e.g. 4.25">
Try It Yourself

How It Works

  1. Default step is 1 for number — integers only unless you change it.
  2. step="any" removes the stepping rule.
  3. min/max still apply if present.
  4. 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.

HTML
<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>
Try It Yourself

How It Works

  1. type="range" shows a slider.
  2. step="10" snaps to 0, 10, 20 … 100.
  3. min/max bound the track.
  4. 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.

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.

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

step sets the allowed increment between valid values on numeric and date/time inputs. It affects spinners, range sliders, and constraint validation.
number, range, date, month, week, time, and datetime-local. It is not used on text or email.
any means no stepping restriction — any value is allowed within other constraints such as min and max.
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.
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).
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

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

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