input

< html‎ | elements
Jump to: navigation, search

input

This article is In Progress.


W3C Candidate Recommendation

Summary

The input element (<input>) is a multipurpose element for representing form widgets. The type of widget depends on the type attribute.


Overview Table

DOM Interface HTMLInputElement

HTML information

Closing Tag The input element is a void element. An input element must have a start tag but must not have an end tag
CSS Display inline
HTML Element Categories flow phrasing interactive

The input element behavior varies depending on the value of its type attribute:

Other valid attributes for the input element are accept, alt, autocomplete, autofocus, checked, dirname, disabled, form, formaction, formenctype, formmethod, formnovalidate, formtarget, height, list, max, maxlength, min, multiple, name, pattern, placeholder, readonly, required, size, src, step, value, width, and global element attributes. Note that some attributes do not apply for certain types.

Internationalization topics related to the input element:


Compatibility

Do you think this data can be improved? You can ask to add by opening an issue or make a pull request.

Desktop

FeaturesChromeFirefoxInternet ExplorerOperaSafari
Basic support
1.0
Yes
1.0
Yes
2
Yes
1.0
Yes
1.0
Yes
type
1.0
Yes
1.0
Yes
2
Yes
1.0
Yes
1.0
Yes
type=button
1.0
Yes
1.0
Yes
3
Yes
1.0
Yes
1.0
Yes
type=checkbox
1.0
Yes
?
Unknown
2
Yes
1.0
Yes
1.0
Yes
type=color
21.0
Yes
?
Unknown
?
none
11.01
Yes
?
none
type=date
5.0
Yes
?
Unknown
?
none
10.62
Yes
?
Partial support
type=datetime
?
Unknown
?
Unknown
?
none
10.62
Yes
?
Partial support
type=datetime-local
5.0
Yes
?
Unknown
?
none
10.62
Yes
?
Partial support
type=email
5.0
Yes
?
Unknown
10
Yes
10.62
Yes
?
Unknown
type=file
1.0
Yes
1.0
Yes
3.02
Yes
1.0
Yes
1.0
Yes
type=hidden
1.0
Yes
1.0
Yes
2
Yes
1.0
Yes
1.0
Yes
type=image
1.0
Yes
?
Unknown
2
Yes
1.0
Yes
1.0
Yes
type=month
5.0
Yes
?
Unknown
?
none
10.62
Yes
?
Partial support
type=number
6.0
Yes
?
Unknown
?
Unknown
10.62
Yes
?
Yes
type=password
1.0
Yes
1.0
Yes
2
Yes
1.0
Yes
1.0
Yes
type=radio
1.0
Yes
?
Unknown
2
Yes
1.0
Yes
1.0
Yes
type=range
5.0
Yes
?
Unknown
10
Yes
10.62
Yes
?
Yes
type=reset
1.0
Yes
1.0
Yes
2
Yes
1.0
Yes
1.0
Yes
type=search
5.0
Yes
?
Unknown
10
Yes
11.01
Yes
?
Yes
type=submit
1.0
Yes
1.0
Yes
2
Yes
1.0
Yes
1.0
Yes
type=tel
5.0
Yes
?
Unknown
10
Yes
11.01
Yes
?
Unknown
type=text
1.0
Yes
1.0
Yes
2
Yes
1.0
Yes
1.0
Yes
type=time
5.0
Yes
?
Unknown
?
none
10.62
Yes
?
Partial support
type=url
5.0
Yes
?
Unknown
10
Yes
10.62
Yes
?
Unknown
type=week
5.0
Yes
?
Unknown
?
none
10.62
Yes
?
Partial support
accept=[file extension]
?
Yes
?
none
10
Yes
?
Unknown
?
none
accept=[MIME type]
8.0
Yes
?
Unknown
10
Yes
10
Yes
?
none
accept=audio/*
?
Yes
?
Unknown
10
Yes
?
none
?
none
accept=video/*
?
Yes
?
Unknown
10
Yes
?
none
?
none
accept=image/*
?
Yes
?
Unknown
10
Yes
?
none
?
none
accesskey
1.0
Yes
?
Yes
6
Yes
1.0
Yes
?
Unknown
mozactionhint
?
none
?
Unknown
?
none
?
none
?
none
autocomplete
17.0
Yes
?
Unknown
5
Yes
9.6
Yes
5.2
Yes
autofocus
5.0
Yes
?
Unknown
10
Yes
9.6
Yes
5.0
Yes
checked
1.0
Yes
1.0
Yes
2
Yes
1.0
Yes
1.0
Yes
disabled
1.0
Yes
1.0
Yes
6
Yes
1.0
Yes
1.0
Yes
form
9.0
Yes
?
Unknown
?
Unknown
10.62
Yes
?
Unknown
formaction
9.0
Yes
?
Unknown
10
Yes
10.62
Yes
5.2
Yes
formenctype
9.0
Yes
?
Unknown
10
Yes
10.62
Yes
?
Unknown
formmethod
9.0
Yes
?
Unknown
10
Yes
10.62
Yes
5.2
Yes
formnovalidate
5.0
Yes
?
Unknown
10
Yes
10.62
Yes
?
Unknown
formtarget
9.0
Yes
?
Unknown
10
Yes
10.62
Yes
5.2
Yes
height
1.0
Yes
?
Unknown
?
Unknown
1.0
Yes
?
Unknown
inputmode
?
none
?
none
?
none
?
none
?
none
list
20.0
Yes
?
Unknown
10
Yes
9.6
Yes
?
none
max
5.0
Yes
?
Unknown
?
Unknown
10.62
Yes
?
Unknown
maxlength
1.0
Yes
1.0
Yes
2
Yes
1.0
Yes
1.0
Yes
min
5.0
Yes
?
Unknown
?
Unknown
10.62
Yes
?
Unknown
minlength
?
Unknown
?
Unknown
?
Unknown
?
Unknown
?
Unknown
multiple
1.0
Yes
?
Partial support
10
Yes
1.0
Yes
?
Unknown
name
1.0
Yes
1.0
Yes
2
Yes
1.0
Yes
1.0
Yes
pattern
5.0
Yes
?
Unknown
10
Yes
9.6
Yes
?
none
placeholder
10.0
Yes
?
Unknown
10
Yes
11.00
Yes
5.0
Yes
readonly
1.0
Yes
1.0
Yes
6
Yes
1.0
Yes
1.0
Yes
required
5.0
Yes
?
Unknown
10
Yes
9.6
Yes
?
none
size
1.0
Yes
1.0
Yes
2
Yes
1.0
Yes
1.0
Yes
spellcheck
10.0
Yes
?
Unknown
10
Yes
11.0
Yes
4.0
Yes
src
1.0
Yes
1.0
Yes
2
Yes
1.0
Yes
1.0
Yes
step
6.0
Yes
?
Unknown
10
Yes
10.62
Yes
5.0
Yes
tabindex
1.0
Yes
1.0
Yes
6
Yes
?
Yes
?
Unknown
width
1.0
Yes
?
Unknown
?
Unknown
1.0
Yes
?
Unknown

Mobile

FeaturesAndroidFirefox MobileIE MobileOpera MobileSafari Mobile
Basic support
?
Yes
4.0
Yes
?
Yes
?
Yes
?
Yes
type
?
Yes
?
Yes
?
Yes
?
Yes
?
Yes
type=button
?
Yes
?
Yes
?
Yes
?
Yes
?
Yes
type=checkbox
?
Yes
?
Yes
?
Yes
?
Yes
?
Yes
type=color
?
Unknown
?
Unknown
?
Unknown
?
Yes
?
Unknown
type=date
?
none
?
none
?
none
10.62
Yes
5.0
Yes
type=datetime
?
none
?
none
?
none
10.62
Yes
?
Yes
type=datetime-local
?
none
?
none
?
none
10.62
Yes
?
Yes
type=email
?
Unknown
4.0
Yes
?
Unknown
?
Yes
3.1
Yes
type=file
?
Unknown
?
Unknown
?
Unknown
?
Unknown
?
Unknown
type=hidden
?
Yes
?
Yes
?
Yes
?
Yes
?
Yes
type=image
?
Yes
?
Yes
?
Yes
?
Yes
?
Yes
type=month
?
none
?
none
?
none
10.62
Yes
?
Yes
type=number
2.3
Yes
29.0
Yes
?
Unknown
?
Yes
4.0
Yes
type=password
?
Yes
?
Yes
?
Yes
?
Yes
?
Yes
type=radio
?
Yes
?
Yes
?
Yes
?
Yes
?
Yes
type=range
?
Unknown
?
none
?
Unknown
?
Yes
5.0
Yes
type=reset
?
Yes
?
Yes
?
Yes
?
Yes
?
Yes
type=search
?
Unknown
4.0
Yes
?
Unknown
10.62
Yes
4.0
Yes
type=submit
?
Yes
?
Yes
?
Yes
?
Yes
?
Yes
type=tel
2.3
Yes
4.0
Yes
?
Unknown
10.62
Yes
3.1
Yes
type=text
?
Yes
?
Yes
?
Yes
?
Yes
?
Yes
type=time
?
none
?
none
?
none
10.62
Yes
?
Yes
type=url
?
Unknown
4.0
Yes
?
Unknown
10.62
Yes
3.1
Yes
type=week
?
none
?
none
?
none
10.62
Yes
?
Yes
accept=[MIME type]
?
Unknown
?
Unknown
?
Unknown
?
Unknown
?
Unknown
accept=audio/*
?
Unknown
?
Unknown
?
Unknown
?
Unknown
?
Unknown
accept=image/*
?
Unknown
?
Unknown
?
Unknown
?
Unknown
?
Unknown
accept=video/*
?
Unknown
?
Unknown
?
Unknown
?
Unknown
?
Unknown
accesskey
?
Unknown
?
Unknown
?
Unknown
?
Unknown
?
Unknown
autocomplete
?
Unknown
4.0
Yes
?
Yes
?
Yes
?
Yes
autofocus
3.2
Yes
4.0
Yes
?
Unknown
?
Yes
?
Unknown
checked
?
Yes
?
Yes
?
Yes
?
Yes
?
Yes
disabled
?
Yes
4.0
Yes
?
Yes
?
Yes
?
Yes
form
?
Unknown
?
Unknown
?
Unknown
?
Unknown
?
Unknown
formaction
?
Unknown
4.0
Yes
?
Unknown
10.62
Yes
5.0
Yes
formenctype
?
Unknown
?
Unknown
?
Unknown
?
Unknown
?
Unknown
formmethod
?
Unknown
4.0
Yes
?
Unknown
10.62
Yes
5.0
Yes
formnovalidate
?
Unknown
4.0
Yes
?
Unknown
10.62
Yes
?
Unknown
formtarget
?
Unknown
4.0
Yes
?
Unknown
10.62
Yes
5.0
Yes
height
?
Unknown
16.0
Yes
?
Unknown
?
Unknown
?
Unknown
list
?
none
4.0
Yes
?
Unknown
?
Yes
?
Unknown
max
?
Unknown
16.0
Yes
?
Unknown
10.62
Yes
?
Unknown
maxlength
?
Yes
4.0
Yes
?
Yes
?
Yes
?
Yes
min
?
Unknown
16.0
Yes
?
Unknown
10.62
Yes
?
Unknown
minlength
?
Unknown
?
Unknown
?
Unknown
?
Unknown
?
Unknown
multiple
?
Unknown
?
Yes
?
Unknown
?
Yes
?
Unknown
name
?
Yes
4.0
Yes
?
Yes
?
Yes
1.0
Yes
pattern
?
Unknown
4.0
Yes
?
Unknown
?
Yes
?
Yes
placeholder
2.3
Yes
4.0
Yes
?
Unknown
11.10
Yes
4
Yes
readonly
?
Yes
4.0
Yes
?
Yes
?
Yes
?
Yes
required
?
Unknown
?
Yes
?
Unknown
?
Yes
?
Unknown
size
?
Yes
4.0
Yes
?
Yes
?
Yes
?
Yes
spellcheck
?
Unknown
4.0
Yes
?
Unknown
11.0
Yes
?
Unknown
src
?
Unknown
?
Unknown
?
Unknown
?
Unknown
?
Unknown
step
?
Unknown
16.0
Yes
?
Unknown
10.62
Yes
?
Unknown
tabindex
?
Unknown
?
Unknown
?
Unknown
?
Unknown
?
Unknown
width
?
Unknown
16.0
Yes
?
Unknown
?
Unknown
?
Unknown

Examples

View live exampleThis example uses the input element to create different types of input controls.

HTML

<form action="http://example.org/survey" method=post>

Name


<input name="control1" type="text" value="Your Name">

Password


<input type="password" name="control2">

Color


<input type="radio" name="control3" value="0" checked>Red <input type="radio" name="control3" value="1">Green <input type="radio" name="control3" value="2">Blue

Comments


<input type="TEXT" name="control4" size="20,5" maxlength="250">

<input name="control5" type=checkbox checked>Send receipt

<input type="submit" value="OK"><input type="reset" value="reset">

</form>

Usage

To cater for international users see: Managing text direction in form controls

Notes

For code samples, see Form controls part 1 and Form controls part 2: validation on the Windows Internet Explorer sample site.

Firefox will, unlike other browsers, by default, persist the dynamic disabled state and (if applicable) dynamic checkedness of an input across page loads. Setting the value of the autocomplete attribute to off disables this feature; this works even when the autocomplete attribute would normally not apply to the input by virtue of its type. See Mozilla bug #654072.

Safari Mobile for iOS applies a default style of opacity: 0.4 to disabled textual input elements. Other major browsers don't currently share this particular default style.


Related specifications

Specification Status Related Changes
HTML5 W3C Candidate Recommendation

See also

Related articles

HTML


















































… further results


External resources

http://www.w3.org/TR/html-markup/input.html#input

Attribution

This article contains content originally from external sources.

Portions of this content come from the Microsoft Developer Network: [Windows Internet Explorer API reference Article]