Definition and Usage
The <input> tag offers a wide range of control types based on the value of its type attribute.
The behavior and appearance of the input field vary depending on the value of the type attribute.
type Attribute
The available type attribute values and their descriptions are summarized below.
If the type attribute is not specified, its default value is text.
type attribute values not supported by some major browsers have been excluded.
type |
Description | Basic Example |
|---|---|---|
<input type="button"> |
This is a button with no default behavior.
It can be used with JavaScript to perform various actions. |
|
<input type="checkbox"> |
This is a checkbox.
It allows a single value to be checked and unchecked. It is generally square, but its corners may be rounded. |
|
<input type="color"> |
This is an input field in the form of a color picker that allows the user to select or enter a color.
It opens a color picker when activated in the browser. |
|
<input type="date"> |
This is a date input control.
It opens a date picker or numeric wheel for the year, month, and day when activated in the browser. |
|
<input type="datetime-local"> |
This is an input field that provides a date and time selection interface for easily entering a date and time at once. | |
<input type="email"> |
This is an email address input field.
It looks like a text input, but on some devices with dynamic virtual keyboards (such as mobile devices), it supports a keyboard that helps with entering email addresses such as the @ and . characters. |
|
<input type="file"> |
This is an input field that allows users to select and upload files from their devices. | |
<input type="hidden"> |
This is a hidden input field that is not visible to users but allows data to be submitted along with the form. | |
<input type="image"> |
This is a form (<form>) submit button displayed as an image rather than text.
Clicking this button submits the values of all submittable controls in the form containing the element. |
|
<input type="number"> |
This is a numeric input field.
It displays a spinner and performs validation to allow only numbers to be entered. On some devices with dynamic virtual keyboards (such as mobile devices), it displays a numeric keypad. |
|
<input type="password"> |
This is a password input field.
The browser hides sensitive information entered by the user by replacing text characters with symbols such as bullets (•), making them unreadable on the screen. |
|
<input type="radio"> |
This is a radio button.
It is generally rendered as a small circle and is filled or highlighted when selected. |
|
<input type="range"> |
This is a range slider that allows a value to be selected within a specified numeric range. | |
<input type="reset"> |
This is a form (<form>) reset button.
When this button is clicked, it resets the values of all controls in the form containing this element. |
|
<input type="search"> |
This is a search term input field.
It is a single-line text input control, and on some devices with dynamic virtual keyboards (such as mobile devices), it supports a search icon. Depending on the browser, it may include a delete icon that can be used to clear the field. |
|
<input type="submit"> |
This is a form (<form>) submit button.
Clicking this button submits the values of all submittable controls in the form containing the element. |
|
<input type="tel"> |
This is a phone number input field.
It is a single-line text input control and does not validate the phone number format. |
|
<input type="text"> |
This is the default value of the type attribute and is a general text input field.
It is a single-line text input control. |
|
<input type="time"> |
This is an input control that provides a time selection interface for easy entry of a time. | |
<input type="url"> |
This is a URL input field.
It looks like a text input, but on some devices with dynamic virtual keyboards (such as mobile devices), it supports a keyboard that helps with entering URLs, with keys for characters such as / and . and keys for quickly entering strings commonly found in domain names, such as www. or .com. |
Good to Know!
The interface or styling of a control based on the value of the type attribute may vary slightly depending on the browser and operating system.
Browser Compatibility
| Attribute Value |
Desktop Chrome
|
Desktop Edge
|
Desktop Firefox
|
Safari
|
|---|---|---|---|---|
type="button"
|
1 | 12 | 1 | 1 |
type="checkbox"
|
1 | 12 | 1 | 1 |
type="color"
|
20 | 14 | 29 | 12.1 |
type="date"
|
20 | 12 | 53 | 14.1 |
type="datetime-local"
|
20 | 12 | 93 | 14.1 |
type="email"
|
5 | 12 | 1 | 5 |
type="file"
|
1 | 12 | 1 | 1 |
type="hidden"
|
1 | 12 | 1 | 1 |
type="image"
|
1 | 12 | 1 | 1 |
type="number"
|
7 | 12 | 29 | 5.1 |
type="password"
|
1 | 12 | 1 | 1 |
type="radio"
|
1 | 12 | 1 | 1 |
type="range"
|
4 | 12 | 23 | 3.1 |
type="reset"
|
1 | 12 | 1 | 1 |
type="search"
|
5 | 12 | 4 | 10.6 |
type="submit"
|
1 | 12 | 1 | 1 |
type="tel"
|
3 | 12 | 1 | 4 |
type="text"
|
1 | 12 | 1 | 1 |
type="time"
|
20 | 12 | 57 | 14.1 |
type="url"
|
1 | 12 | 1 | 1 |
Specifications
| Specification | |
|---|---|
<input type="value">
|
HTML Standard #attr-input-type |