Example
An HTML form with two different input types; text and submit:
<form action=”/action_page.php”>
Username: <input type=”text” name=”usrname”><br>
<input type=”submit” value=”Submit”>
</form>
More “Try it Yourself” examples below.
Definition and Usage
The type attribute specifies the type of <input> element to display.
The default type is text.
Tip: The type attribute is not a required attribute, but we think you should always include it.
Browser Support
| Attribute | |||||
|---|---|---|---|---|---|
| type | Yes | Yes | Yes | Yes | Yes |
Note: The type attribute works in all major browsers. However, not all the different input types works in all major browsers.
Look below to see browser support for each input type.
Differences Between HTML 4.01 and HTML5
HTML5 has the following new input types: color, date, datetime-local, month, week, time, email, number, range, search, tel, and url.
<input type=”value“>
Attribute Values
| Value | Description |
|---|---|
| button | Defines a clickable button (mostly used with a JavaScript to activate a script) |
| checkbox | Defines a checkbox |
| color | Defines a color picker |
| date | Defines a date control (year, month, day (no time)) |
| datetime-local | Defines a date and time control (year, month, day, time (no timezone) |
| Defines a field for an e-mail address | |
| file | Defines a file-select field and a “Browse” button (for file uploads) |
| hidden | Defines a hidden input field |
| image | Defines an image as the submit button |
| month | Defines a month and year control (no timezone) |
| number | Defines a field for entering a number |
| password | Defines a password field |
| radio | Defines a radio button |
| range | Defines a range control (like a slider control) |
| reset | Defines a reset button |
| search | Defines a text field for entering a search string |
| submit | Defines a submit button |
| tel | Defines a field for entering a telephone number |
| text | Default. Defines a single-line text field |
| time | Defines a control for entering a time (no timezone) |
| url | Defines a field for entering a URL |
| week | Defines a week and year control (no timezone) |
