"The right input type isn't decoration — it summons the right keyboard, the right validation, the right autocomplete, the right hardware integration. All from one attribute."
Why Type Matters More Than You'd Think
Every type beyond the default text changes four things at once:
- The on-screen keyboard on mobile.
type="email"shows the @ key without making the user toggle to symbols.type="tel"shows the numeric keypad.type="url"shows the / and .com keys. - Built-in validation.
type="email"rejects strings without an @;type="url"rejects malformed URLs;type="number"rejects non-numeric. - Autocomplete.
type="email"+autocomplete="email"tells the browser to offer the user's saved email.type="password"+autocomplete="new-password"triggers password manager generation. - Hardware/OS integration.
type="file"opens the OS file picker;type="color"opens the OS color picker;type="date"opens a date picker. No custom JS needed for any of these.
Text-Like Types
type="text"— default. Single-line text.type="email"— single email (or comma-separated withmultiple).type="password"— masked input. Pair withautocomplete="current-password"for sign-in,"new-password"for sign-up.type="url"— URL with validation.type="tel"— telephone number. Note: no validation (phone formats vary too much globally); usepatternif you need format checking. The point is the mobile numeric keyboard.type="search"— text input with a built-in clear-X button in some browsers.
Numeric And Range Types
type="number"— numeric input with up/down spinner. Usemin,max,stepfor constraints. Note: not for credit cards or phone numbers (usetextwithinputmode="numeric"for those — number type strips leading zeros and won't allow non-numeric formatting).type="range"— slider. Show the current value with a<output>element + JavaScript.
Date And Time Types
type="date"— YYYY-MM-DD. Opens native date picker.type="datetime-local"— date + time, no timezone.type="time"— HH:MM.type="month",type="week"— for billing periods, sprints, etc.
The native date picker is wildly better than building one in JavaScript. Locale-aware, accessible, keyboard-navigable. Reach for a custom date picker only when you need calendar features the native one lacks (date ranges, custom highlighting).
Selection Types
type="checkbox"— independent on/off. Multiple in a group, multiple selectable.type="radio"— mutually exclusive group. Samenameties them together; only one selectable.type="file"— file picker.accept="image/*"filters;multipleallows multi-select;capture="environment"on mobile opens the camera.type="color"— color picker. Value is a hex string.type="hidden"— invisible, value sent with form. For CSRF tokens, IDs, etc.
Multi-Line And Dropdowns
<textarea> for multi-line text. rows and cols for default size; CSS for responsive sizing.
<select> + <option> for dropdowns. Use <optgroup label="..."> for grouped options. The default styling is platform-native and often ugly, which is why custom dropdowns exist — but custom dropdowns need full ARIA + keyboard + mobile work to match what <select> gives you for free. Memory rule: prefer native unless you can afford to do the full custom job.
type="email" matters, hold a phone, tap a generic type="text" field, and try to type your email. Then compare to type="email". That single attribute is hours of cumulative user time across an app's lifetime.inputmode: The Mobile-Only Keyboard Hint
Some fields are text by semantic but should show a numeric keyboard (a credit-card number, an OTP). inputmode hints at the keyboard without changing the type:
inputmode="numeric"— number pad, no validation, accepts non-numeric characters if needed.inputmode="decimal"— number pad with a decimal point.inputmode="tel"— phone keypad.inputmode="email","url","search"— specialized keyboards.
Pippa's Note
type="text" but inputmode="text" with smart enter handling. The volume slider in settings is type="range" with a paired <output> showing the current value. The TTS voice file upload is type="file" accept="audio/*". None of these needed a third-party library — the platform already had the right tool.