HTML <input> Tag with the 'type' Attribute
<form name="myForm" action="/resources/html-forms-action.cfm">
<input type="range" name="myField">
<button>Submit</button>
</form>
The above example demonstrates usage of the <input> element with the type attribute.
The type attribute controls the data type (and associated control) of the element. The default value is text. In other words, if the type attribute is not present, the input control will be a text control.
Possible Values
The type attribute accepts the following values.
| Value | Data Type | Control Type |
|---|---|---|
hidden | An arbitrary string | N/A |
text | Text with no line breaks | Text field |
search | Text with no line breaks | Text field |
tel | Text with no line breaks | Text field |
url | An absolute IRI | Text field |
email | An email address or list of email addresses | Text field |
password | Text with no line breaks (sensitive information) | Text field that obscures data entry (eg, hides the password by using asterisks (******) or similar) |
datetime | A date and time (year, month, day, hour, minute, second, fraction of a second) with the time zone set to UTC | Date and time control |
date | A date (year, month, day) with no time zone | Date control |
month | A date consisting of a year and a month with no time zone | A month control |
week | A date consisting of a week-year number and a week number with no time zone | A week control |
time | A time (hour, minute, seconds, fractional seconds) with no time zone | A time control |
datetime-local | A date and time (year, month, day, hour, minute, second, fraction of a second) with no time zone | Date and time control |
number | A numerical value | Text field or spinner control |
range | A numerical value, with the extra semantic that the exact value is not important | Slider control or similar |
color | An sRGB color with 8-bit red, green, and blue components | A color well. Enables the user to select a color. |
checkbox | A set of zero or more values from a predefined list | Checkbox |
radio | An enumerated value | Radio button |
file | Zero or more files each with a MIME type and optionally a file name | A label and a button |
submit | An enumerated value, with the extra semantic that it must be the last value selected and initiates form submission | Button |
image | A coordinate, relative to a particular image's size, with the extra semantic that it must be the last value selected and initiates form submission | Either a clickable image, or a button |
reset | N/A | Button |
button | N/A | Button |