HTML - <input type="password">

The HTML <input type="password"> element is a specific version of the <input> element, used to create an input field accepting a password.

Example

 

To create a widget to display a password, use:

HTML
<input type="password">

To create a widget to display a password with pattern, use:

HTML
<input type="password" pattern=".{6,}">

The above example will create password element that must contain 6 or more characters.

Description  

The HTML <input type="password"> element is a specific version of the <input> element, used to create an input field accepting a password.

The browser will generate a input field for entering, and changing, the password. The data which the user enters will be displayed in a Asterisks character, this character can vary from browser to browser.

Content categories Flow content, listed, submittable, resettable, form-associated element, phrasing content, labellable element, palpable content.
Permitted content None, it is an empty element.
Tag omission Must have a start tag and must not have an end tag.
Permitted parent elements Any element that accepts phrasing content.
DOM interface HTMLInputElement

Browser Compatibility  

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0 1.0 (1.7 or earlier) 2 1.0 1.0
accesskey 1.0 (Yes) 6 1.0 ?
autocomplete 17.0 4.0 (2.0) 5 9.6 5.2
autofocus 5.0 4.0 (2.0) 10 9.6 5.0
disabled 1.0 1.0 (1.7 or earlier)[4] 6 1.0 1.0
form 9.0 4.0 (2.0) ? 10.62 ?
formaction 9.0 4.0 (2.0) 10 10.62 5.2
formenctype 9.0 4.0 (2.0) 10 10.62 ?
formmethod 9.0 4.0 (2.0) 10 10.62 5.2
formnovalidate 5.0[1] 4.0 (2.0) 10 10.62 ?
formtarget 9.0 4.0 (2.0) 10 10.62 5.2
inputmode No support No support No support No support No support
list 20.0 4.0 (2.0) 10 9.6 No support
maxlength 1.0 1.0 (1.7 or earlier) 2 1.0 1.0
minlength 40.0 ? ? ? ?
name 1.0 1.0 (1.7 or earlier) 2 1.0 1.0
pattern 5.0 4.0 (2.0) 10 9.6 No support
placeholder 10.0 4.0 (2.0) 10 11.00 5.0
readonly 1.0 1.0 (1.7 or earlier) 6[2] 1.0 1.0
required 5.0
10[3]
4.0 (2.0) 10 9.6 No support
size 1.0 1.0 (1.7 or earlier) 2 1.0 1.0
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) 4.0 (2.0) (Yes) (Yes) (Yes)
accesskey ? ? ? ? ?
autocomplete ? 4.0 (2.0) (Yes) (Yes) (Yes)
autofocus 3.2 4.0 (2.0) ? (Yes) ?
disabled (Yes) 4.0 (2.0) (Yes) (Yes) (Yes)
form ? ? ? ? ?
formaction ? 4.0 (2.0) ? 10.62 5.0
formenctype ? ? ? ? ?
formmethod ? 4.0 (2.0) ? 10.62 5.0
formnovalidate ? 4.0 (2.0) ? 10.62 ?
formtarget ? 4.0 (2.0) ? 10.62 5.0
inputmode No support No support No support No support No support
list No support 4.0 (2.0) ? (Yes) ?
maxlength (Yes) 4.0 (2.0) (Yes) (Yes) (Yes)
minlength ? ? ? 27.0 ?
name (Yes) 4.0 (2.0) (Yes) (Yes) 1.0
pattern ? 4.0 (2.0) ? (Yes) (Yes)
placeholder 2.3 4.0 (2.0) ? 11.10 4
required ? (Yes) ? (Yes) ?
size (Yes) 4.0 (2.0) (Yes) (Yes) (Yes)

 

[1] In 6.0 it only worked with the HTML5 document type, validation support in 7.0 was disabled and re-enabled in 10.0.

[2] Missing for type="checkbox" and type="radio".

[3] Supported for <select> element.

[4] 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 bug 654072.

Specifications  

Specification Status Comment
WHATWG HTML Living Standard
The definition of '<input>' in that specification.
Living Standard  
HTML5
The definition of '<input>' in that specification.
Recommendation  
HTML 4.01 Specification
The definition of '<form>' in that specification.
Recommendation  

License

© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/html/element/input/password

Element HTML Reference