Help Center

Local Navigation

Input types

The following are valid values for the type attribute of the <input> element.

button

Availability

version 3.7 or later

Valid attributes

name, value

Specifying this input type causes the browser to render a button control. The value attribute specifies the text of the button.

checkbox, radio

Availability

version 3.7 or later

Valid attributes

checked, name (required), placeholder, readonly, required, size, value

Specifying this input type causes the browser to render a check box or radio button control. You can use check boxes and radio buttons anywhere in a form element.

color

Availability

version 4.7.1 or later

Valid attributes

name (required), value

Specifying this input type causes the browser to render a color picker control that enables users to select a color.

date, datetime, datetime-local, month, time, week

Availability

version 4.7.1 or later

Valid attributes

max, min, name (required), readonly, required, value

Specifying one of these input types causes the browser to render a time or date picker control. Users can specify the values that are appropriate to the specific input type.

The browser rounds time values to the nearest minute and sets the value for the seconds and milliseconds to 0.

For the datetime input type, the browser sets the time zone as UTC.

If you specify the value, max or min attributes, you must specify a valid value for this input type.

On devices with a trackball, users can change the date or time by using the keyboard or by rolling the trackball. On devices with a touch screen, users can change the date or time by touching the screen.

email

Availability

version 4.7.1 or later

Valid attributes

inputmode, list, maxlength, name (required), placeholder, readonly, required, size, value

Specifying this input type causes the browser to render an email control. An email control is a text field that accepts only an email address.

Users can press the Space key to insert an at sign (@) or a period (.) in an email address.

file

Availability

version 4.2 or later

Valid attributes

accept, name (required), required, value

Specifying this input type causes the browser to render a button control that opens a dialog box in which users can browse for a file. The browser displays the file name of the selected file in the form, and includes the file when the user submits the form.

hidden

Availability

version 3.7 or later

Valid attributes

name (required), value

Specifying this input type causes the browser not to render anything, but does include the element's associated name and value attributes when the user submits the form.

You can use the hidden input type to create offline form submission queues for the . For more information about form submission queues, see the Fundamentals Guide.

image

Availability

version 3.7 or later

Valid attributes

alt, name (required), src, value

Specifying this input type causes the browser to render the specified image, which functions as a button.

number

Availability

version 4.7.1 or later

Valid attributes

list, name (required), required, value

Specifying this input type causes the browser to render a text field control that accepts only numerical values.

password

Availability

version 3.7 or later

Valid attributes

inputmode, maxlength, name (required), placeholder, readonly, required, size, value

Specifying this input type causes the browser to render a password control. A password control is a text field that obscures the value by displaying an asterisk (*) for each character that the user types.

The browser includes the actual encoded value when the user submits the form.

range

Availability

version 4.7.1 or later

Valid attributes

max, min, name (required), step, value

Specifying this input type causes the browser to render a slide bar control.

On devices with a trackball, users can change the value by using the keyboard or by rolling the trackball. On devices with a touch screen, users can change the value by touching the screen.

If you do not specify the max, min, and step attributes, the browser specifies a default max value of 100, a default min value of 0, and a default step value of 1.

reset

Availability

version 3.7 or later

Valid attributes

value

Specifying this input type causes the browser to render a button control that users can click to reset the form values to the original values. This does not affect other forms on the screen.

search

Availability

version 4.7.1 or later

Valid attributes

inputmode, list, maxlength, name (required), placeholder, readonly, required, size, value

Specifying this input type causes the browser to render a text field control that accepts a single line of text with no line breaks.

submit

Availability

version 3.7 or later

Valid attributes

value

Specifying this input type causes the browser to render a button control that users click to submit the form values to the specified server.

On submit, the browser passes the form values to the server and opens the URL that the action attribute of the <form> element specifies.

text

Availability

version 3.7 or later

Valid attributes

inputmode, list, maxlength, name (required), placeholder, readonly, required, size, value

Specifying this input type causes the browser to render a text field control that accepts a single line of text with no line breaks.

url

Availability

version 4.7.1 or later

Valid attributes

inputmode, list, maxlength, name (required), placeholder, readonly, required, size, value

Specifying this input type causes the browser to render a text field control that only accepts a web address. Users can press the Space key to insert a period (.) in a web address.

This input type verifies that the syntax of the entered URL is valid. It does not verify that the supplied web address exists.

Index


Was this information helpful? Send us your comments.