HTML Input Types
HTML Living Standard
The type attribute controls what kind of input the browser shows and which values it accepts. HTML defines 22 current input types. Pick one by the kind of information you want to collect or the action the control should perform.
On this page
Text and contact fields
- Text input (type="text")
Use a single-line text field for names and other short text. The text type is also the default when type is omitted.
- Search field (type="search")
Collect a search query in a single line. Some browsers add a clear button.
- Telephone input (type="tel")
Collect a phone number. A mobile browser can show a telephone keyboard. Add a suitable pattern if you require a particular format.
- URL input (type="url")
Collect a web address. A nonempty value must have a valid absolute URL format to pass native validation.
- Email input (type="email")
Collect an email address and check its format in the browser. The format check cannot confirm that an inbox exists.
- Password input (type="password")
Hide the characters while the user types. Use login or signup autocomplete hints so password managers can help.
Date and time fields
- Date input (type="date")
Collect a year, month, and day. The value uses the YYYY-MM-DD format.
- Month input (type="month")
Collect a year and month. The value uses the YYYY-MM format. Browsers without a month picker can show a text input.
- Week input (type="week")
Collect a year and ISO week number. A value such as 2026-W48 identifies week 48. Some browsers fall back to a text field.
- Time input (type="time")
Collect a time without a date or time zone. Its value uses 24-hour time regardless of how it is shown.
- Local date and time input (type="datetime-local")
Collect a date and time without a time-zone offset. Ask for the time zone separately when it matters.
Numbers and pickers
- Number input (type="number")
Use this input for numeric quantities. Use a text field for digit strings such as IDs that can begin with zero.
- Range slider (type="range")
Let the user choose an approximate number with a slider. Add an adjacent readout when the exact value matters.
- Color picker (type="color")
Open the browser’s color picker. A six-digit hex color works across common browser implementations.
Choices and files
- Checkbox (type="checkbox")
Let users turn an option on or off. Checkboxes are independent even when they share a name.
- Radio button (type="radio")
Radio buttons with the same name in a form allow one selected option.
- File picker (type="file")
Allow users to choose local files. An upload form usually submits with POST and multipart/form-data.
Form actions and hidden values
- Hidden input (type="hidden")
Include a value when submitting a form without showing a field. A user can still inspect or change the value in the browser.
- Submit input (type="submit")
Submit the surrounding form, after native validation when enabled.
- Image submit input (type="image")
Use an image as a submit control. Give it alt text that describes the action.
- Reset input (type="reset")
Restore form controls to their initial values. Use it only when users expect a reset action.
- Button input (type="button")
Creates a push button with no built-in form action. Add JavaScript for the behavior you want.
Collect several lines with <textarea>
A textarea accepts line breaks. rows sets the initial visible height in lines. Put initial text between the tags. In JavaScript, read the current editable text from .value.
How to try it Save this example as a new .html file, then open it in your browser. After a change, save and reload.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Collect several lines with <textarea></title>
</head>
<body>
<label for="note">Order note</label><br>
<textarea id="note" name="note" rows="3">Less sugar</textarea>
<pre id="result"></pre>
<script>
const note = document.querySelector("#note");
const preview = () => document.querySelector("#result").textContent = note.value;
note.addEventListener("input", preview);
preview();
</script>
</body>
</html>
What to expect Edit the note and add a new line. The text below updates immediately.