HTML reference

input min and max

The min and max attributes describe the smallest and largest allowed value for supported inputs such as numbers, dates, and times.

What you will learn

  • What range min and max describe
  • How step affects valid values
  • Why browser validation does not replace server validation

Basic example

<label for="age">Age</label>
<input id="age" name="age" type="number" min="0" max="120" step="1">

A value below min or above max is invalid for constraint validation. The attributes guide the browser UI, but they do not make untrusted input safe.

Combining with step

<input type="number" min="0" max="10" step="0.5">

Here, values such as 0, 0.5, and 1 are valid points in the range. Check the input type's rules and choose a step that matches the unit users understand.

Dates and times

<input type="date" min="2026-01-01" max="2026-12-31">

Date and time values use their documented machine-readable formats. Test the experience in the browsers and locales your users rely on.

Server-side validation

Users can send requests without your form, and browsers can be bypassed. Validate the range again on the server before storing data or performing an action.

Related pages