Pick the right input type
The type attribute on <input> controls the control rendered, the validation
applied, and — crucially on mobile — which on-screen keyboard appears. This
reference lists every standard input type with the attributes it accepts and the
keyboard it triggers, so you can choose the most specific type for each field.
How it works
Each type maps to a value space and a default control. The browser validates the value against the type before form submission and exposes the result through the Constraint Validation API:
<input type="email" required>
<input type="number" min="0" max="100" step="5">
<input type="tel" inputmode="numeric" pattern="[0-9]{10}">
On mobile, type selects the keyboard: email adds @, url adds /, tel
shows a phone pad, and number/numeric show digits. Unsupported types degrade
gracefully to text, so always supply sensible attributes and a fallback.
Tips and notes
- Use the most specific type available — it is the cheapest accessibility and UX win.
- Pair
type="text"withinputmodewhen you need a keyboard hint without strict validation (e.g. card numbers that need spaces). type="password"masks input but offers no validation — addpattern/minlength.type="search"adds a clear button on most browsers;type="hidden"is never rendered and submits a fixed value.- For
date/timetypes the submitted value uses a fixed ISO format regardless of the locale shown to the user.