The <input> element's type attribute changes what it collects and how it behaves — the right type gives the right keyboard on mobile and built-in validation for free.
Common input types
| type | For |
|---|---|
| text | General short text |
| email / url / tel | Validated formats + mobile keyboards |
| password | Masked input |
| number / range | Numeric entry / slider |
| date / time | A date/time picker |
| checkbox / radio | Multiple / single choice |
| file | File upload |
| color / search / hidden | Specialised inputs |
Key takeaways
- 01The type attribute sets what an <input> collects and how it behaves.
- 02Types include text, email, password, number, date, checkbox, radio, file and more.
- 03The right type gives format validation and the correct mobile keyboard for free.
- 04Use the most specific type for better UX.
