HTML Reference ยท Forms
The <input> types
Reference for every HTML <input> type value, from text and email to date, range, color, file and image: purpose, attributes, value format, examples and notes.
The type attribute of <input> decides what kind of control you get. There are 22 values. If type is missing or unknown, the browser uses text, so older browsers fall back to a plain text field instead of breaking.
This page has one section per type. For the full list of attributes and which types they apply to, see the <input> attribute table.
| Group | Types |
|---|---|
| Text entry | text, search, email, url, tel, password |
| Numbers | number, range |
| Dates and times | date, time, datetime-local, month, week |
| Pickers | color, file |
| Choices | checkbox, radio |
| Not visible | hidden |
| Buttons | submit, reset, button, image |
Try it
Notice the value formats in the output: dates are always yyyy-mm-dd and colors are always lowercase hex, whatever the picker displays.
text
The default type: a single-line text field. Line breaks are removed from its value.
- Attributes:
autocomplete,dirname,list,maxlength,minlength,pattern,placeholder,readonly,required,size. - Value: any text without line breaks.
<label for="full-name">Full name</label> <input type="text" id="full-name" name="full_name" autocomplete="name">
Use it for anything that has no more specific type. For codes made of digits, add inputmode="numeric" rather than switching to number.
search
A text field meant for search queries. It works like text, but browsers may show a clear button, and some style it differently.
- Attributes: same as
text. - Value: any text without line breaks.
<label for="site-q">Search the docs</label> <input type="search" id="site-q" name="q" enterkeyhint="search">
It is exposed to assistive technology as a searchbox. Wrap a site search in a <search> element so it becomes a search landmark.
A field for an email address, or several with multiple.
- Attributes: text attributes plus
multiple. - Value: a valid email address (
[email protected]), or a comma-separated list withmultiple. Leading and trailing spaces are stripped.
<label for="work-email">Work email</label> <input type="email" id="work-email" name="email" autocomplete="email" required>
Validation only checks the general shape (something @ something); it can't tell whether the address exists. Mobile keyboards show an @ key.
url
A field for an absolute URL.
- Attributes: same as
text. - Value: an absolute URL including its scheme, such as
https://example.com/.
<label for="site">Your website</label> <input type="url" id="site" name="site" placeholder="https://">
example.com without a scheme fails validation, which surprises users. Say so in the label or prefill https://.
tel
A field for a telephone number.
- Attributes: same as
text. - Value: any text. There is no built-in format check, because phone formats vary so much between countries.
<label for="phone">Phone</label> <input type="tel" id="phone" name="phone" autocomplete="tel">
Its main benefit is the phone keypad on mobile devices. Add a pattern only if you really accept a single format.
password
A text field that hides what is typed.
- Attributes:
autocomplete,maxlength,minlength,pattern,placeholder,readonly,required,size. Notlist. - Value: any text without line breaks.
<label for="pw">Choose a password</label> <input type="password" id="pw" name="password" autocomplete="new-password" minlength="12">
Use autocomplete="new-password" on sign-up and current-password on sign-in so password managers behave correctly. Only send passwords over HTTPS with method="post".
number
A field for a number, usually with up and down spinner buttons.
- Attributes:
autocomplete,list,max,min,placeholder,readonly,required,step. - Value: a floating-point number using
.as the decimal separator, such as3or-0.25. The browser may display a localized format. Empty if the text can't be parsed.
<label for="qty">Quantity</label> <input type="number" id="qty" name="qty" min="1" max="99" value="1">
The default step is 1, so decimals fail validation unless you set step="0.01" or step="any". Don't use number for IDs, card numbers or postal codes.
range
A slider for picking a number where the exact value matters less than its position.
- Attributes:
autocomplete,list,max,min,step. - Value: a number. Defaults:
min0,max100,step1, and the initial value is halfway betweenminandmax.
<label for="brightness">Brightness</label> <input type="range" id="brightness" name="brightness" min="0" max="10" value="6">
The slider never shows its number. Display it with an <output> if users need to see it. A list pointing to a <datalist> adds tick marks in most browsers.
date
A date picker for a year, month and day.
- Attributes:
autocomplete,list,max,min,readonly,required,step(in days). - Value:
yyyy-mm-dd, for example2026-10-14. The displayed format follows the user's locale, but the value doesn't.
<label for="arrive">Arrival date</label> <input type="date" id="arrive" name="arrive" min="2026-01-01">
Pickers look different in every browser and can't be styled much. For birthdays far in the past, three separate fields can be easier than scrolling a calendar.
time
A time of day without a date or time zone.
- Attributes:
autocomplete,list,max,min,readonly,required,step(in seconds, default 60). - Value: 24-hour
hh:mm, orhh:mm:ss(and fractions) when the step allows seconds. For example14:05.
<label for="alarm">Alarm time</label> <input type="time" id="alarm" name="alarm" value="07:00">
The control may show a 12-hour clock with AM/PM, but the value is always 24-hour. min can be greater than max to allow a range that crosses midnight.
datetime-local
A date and time together, with no time zone.
- Attributes:
autocomplete,list,max,min,readonly,required,step(in seconds, default 60). - Value:
yyyy-mm-ddThh:mm, such as2026-10-14T18:30, with optional seconds.
<label for="meet">Meeting starts</label> <input type="datetime-local" id="meet" name="starts_at">
The value is local wall-clock time. If the time zone matters, ask for it separately or work it out on the server.
month
A year and month.
- Attributes:
autocomplete,list,max,min,readonly,required,step(in months). - Value:
yyyy-mm, such as2026-10.
<label for="expiry">Expiry month</label> <input type="month" id="expiry" name="expiry">
Some desktop browsers don't offer a month picker and show a plain text field instead, so describe the expected format in the label.
week
A year and an ISO 8601 week number.
- Attributes:
autocomplete,list,max,min,readonly,required,step(in weeks). - Value:
yyyy-Www, such as2026-W42. Weeks start on Monday, and week 1 is the week containing the year's first Thursday.
<label for="sprint">Sprint week</label> <input type="week" id="sprint" name="sprint">
Support is patchier than for date; some browsers fall back to a text field.
color
A color picker.
- Attributes:
autocomplete,list, and the neweralphaandcolorspace. - Value: a lowercase hex color
#rrggbb, such as#0ea5e9. The default is#000000; there is no empty value.
<label for="theme">Theme color</label> <input type="color" id="theme" name="theme" value="#f97316">
Because the value is never empty, required doesn't apply.
file
A button that opens the device's file picker.
- Attributes:
accept,capture,multiple,required. - Value: the selected files, available in JavaScript as
input.files. Thevalueproperty reports a fake path likeC:\fakepath\photo.jpg, and you can't set it from a script (except to an empty string).
<label for="cv">Upload your CV (PDF)</label> <input type="file" id="cv" name="cv" accept=".pdf,application/pdf">
To actually send the file, the form needs method="post" and enctype="multipart/form-data". accept only filters the picker; check the type on the server.
checkbox
A box that is either checked or not, for yes/no choices and "choose any" lists.
- Attributes:
checked,required,value. - Value: the
valueattribute (defaulton), sent only when checked. Unchecked boxes send nothing.
<label> <input type="checkbox" name="terms" value="accepted" required> I accept the rental terms </label>
For several options, give the boxes the same name: each checked box adds its own pair. The indeterminate state (a dash) can only be set from JavaScript and is visual only.
radio
One option in a group where only one can be chosen. A group is all radios in the same form with the same name.
- Attributes:
checked,required,value. - Value: the checked radio's
value(defaulton). Nothing is sent if none is checked.
<fieldset> <legend>Seat</legend> <label><input type="radio" name="seat" value="window" checked> Window</label> <label><input type="radio" name="seat" value="aisle"> Aisle</label> </fieldset>
Arrow keys move the selection inside a group. Wrap the group in a <fieldset> with a <legend>, and give each radio its own value.
hidden
A value that is submitted but not shown or editable by the user.
- Attributes:
autocomplete,name,value. Most others have no effect. - Value: any text, set in the HTML or by a script.
<input type="hidden" name="order_id" value="58213">
Hidden doesn't mean secret: the value is visible in the page source and can be changed by anyone. A hidden input needs no label because it isn't shown.
submit
A button that submits its form. Its value is the button text.
- Attributes:
value,formaction,formenctype,formmethod,formnovalidate,formtarget,popovertarget,popovertargetaction. - Value: if the button has a
name, itsvalueis submitted when it is the button that was clicked.
<input type="submit" value="Place order">
A <button> does the same job and can contain HTML, so it's usually the better choice.
reset
A button that restores every control in the form to its initial value.
- Attributes:
value,popovertarget,popovertargetaction. - Value: never submitted;
valueis the button text (the default text depends on the browser and language).
<input type="reset" value="Start over">
Reset buttons are easy to click by mistake and wipe out the user's work. Only include one if users really need it.
button
A button with no default action, for use with JavaScript or popovertarget.
- Attributes:
value,popovertarget,popovertargetaction. - Value: never submitted;
valueis the button text.
<input type="button" value="Copy link" id="copy">
Without a value the button is blank. <button type="button"> is the modern equivalent.
image
A submit button drawn as an image. Clicking it submits the form along with the click coordinates.
- Attributes:
alt(required),src,width,height, and theform*overrides. - Value: submits
name.xandname.y(or justxandywithout aname): the click position in pixels inside the image. Itsvalueattribute is not used.
<input type="image" src="/samples/sunset.svg" alt="Search" width="48" height="48">
The alt text is the button's accessible name, so describe the action ("Search"), not the picture. A <button> containing an <img> is usually more flexible.
Usage notes
- Fallback is
text. An unsupported type renders as a text field, so your form still works in very old browsers, just with fewer helpers. - Values have fixed formats. Whatever the picker displays, the submitted value uses the formats above. Parse those on the server, not the localized text.
- Pick the type for the data, not the look. The right type gives mobile users the right keyboard, adds validation and helps autofill.
- Labels for every visible type. Every type except
hiddenneeds a label; the button types get theirs fromvalue(oraltforimage).
Browser support
All 22 types are supported in current browsers. month and week still fall back to text fields in some desktop browsers, and the appearance of date, time, color and file pickers varies between platforms.
Related
<input>โ the element and its full attribute table<button>โ the flexible alternative to the button types<label>โ naming each control<datalist>โ suggestions for text, number, date and color types- Lesson: Input Types
- Lesson: Input Attributes
- Lesson: Checkboxes and Radio Buttons
- Lesson: Form Validation