HTML Input Types
Master all HTML input types - from basic text fields to specialized controls like date pickers, color choosers, and file uploads. Learn their unique features, validation, and best practices.
What input types are available in HTML?
HTML offers more than 20 input types. Besides text and password, there are email, url, tel, number, range, date, time, datetime-local, month, week, color, search, file, checkbox, radio and hidden. Choosing the right type gives users the right mobile keyboard, built-in validation and native pickers for free.
<input type="email" name="email"> <!-- @ keyboard + validation -->
<input type="tel" name="phone"> <!-- number pad -->
<input type="number" min="1" max="10">
<input type="date" name="dob">
<input type="range" min="0" max="100">
<input type="color" value="#3b82f6">Input Types Overview
HTML5 introduced numerous input types that provide native validation, improved user experience, and specialized interfaces for different data types. Each input type has unique characteristics, validation rules, and browser behaviors.
Input Type Categories:
- Text Types: text, email, password, search, url, tel
- Number Types: number, range
- Date/Time: date, time, datetime-local, month, week
- Choice Types: checkbox, radio, color, file
- Button Types: submit, reset, button, image
- Hidden: hidden
Complete Input Types Guide
Text Input Types
text (default)
Single-line text input. Most versatile and widely supported.
<input type="text" name="username">Email address input with built-in validation. Shows email keyboard on mobile.
<input type="email" name="email">password
Password input with masked characters. Never cached by browsers.
<input type="password" name="pwd">search
Search input with clear button. Styled as search field on mobile.
<input type="search" name="q">url
URL input with validation. Shows URL keyboard on mobile devices.
<input type="url" name="website">tel
Telephone number input. Shows numeric keypad on mobile devices.
<input type="tel" name="phone">Number Input Types
number
Numeric input with spinner controls. Supports min, max, and step attributes.
<input type="number" min="1" max="100" step="1">- • Shows numeric keyboard on mobile
- • Built-in validation for numeric values
- • Supports decimal and negative numbers
range
Slider control for selecting a value within a range. Great for settings and preferences.
<input type="range" min="0" max="100" value="50">- • Visual slider interface
- • Touch-friendly on mobile devices
- • Pair with output element for display
Date and Time Input Types
date
Date picker (YYYY-MM-DD format)
time
Time picker (HH:MM format)
datetime-local
Date and time picker (local timezone)
month
Month and year picker
Date/Time Features:
- Native date/time pickers in modern browsers
- Automatic format validation
- Locale-aware display
- Support for min/max constraints
- Limited styling capabilities
- Fallback to text input in older browsers
Interactive Input Types Demo
Try all HTML input types in this interactive demo. See how they behave, their validation, and their unique features across different browsers and devices.
Code Editor
<label>email <input type="email"></label>
<label>tel <input type="tel"></label>
<label>number <input type="number" min="1" max="10"></label>
<label>range <input type="range"></label>
<label>date <input type="date"></label>
<label>color <input type="color" value="#2563eb"></label>
<label>search <input type="search"></label>
<label>PIN <input inputmode="numeric" pattern="[0-9]*"></label>Preview
Browser Support & Validation
Excellent Support
- • text, password, email, url
- • number, range
- • checkbox, radio, submit
- • hidden, button, reset
Partial Support
- • date, time, datetime-local
- • month, week
- • color, search
- • tel (limited validation)
Important Validation Notes
- • Client-side validation can be bypassed
- • Always implement server-side validation
- • Test across different browsers
- • Provide fallback experiences
- • Consider polyfills for older browsers
- • Use novalidate attribute for custom validation
- • Implement progressive enhancement
- • Test on mobile devices
HTML Input Types — step by step
Use type='text' for general text
The default input type accepts any text. Add placeholder for hint text and maxlength to limit entry. Always pair with a label element.
🎯 Quick Check
Which input type automatically shows a numeric keypad on mobile and restricts entry to numbers?
HTML Input Types: summary
Key points
- For numeric codes like PINs or card numbers, use
type="text" inputmode="numeric"rather thantype="number". type="email"andtype="url"validate the format before the form submits.- Unsupported types fall back to a plain text field, so they're safe to use.
Frequently asked questions
›Should I use type="number" for phone numbers?
No. Use type="tel". Phone numbers can have leading zeros, plus signs and spaces, and they aren't quantities.
›How do I show a numeric keyboard on mobile?
Use inputmode="numeric" (digits only) or inputmode="decimal" on a text input.