Input Types

HTML input type="password"

Build a form with the HTML form generator

Mask the displayed characters. Masking does not encrypt data or replace HTTPS. Use the current-password or new-password autocomplete token as appropriate. Never log or expose entered credentials. Use only attributes applicable to this input state; the browser ignores or rejects unrelated constraints. Validate submitted data on the server.

Formal Syntax & Structure

html syntaxhtml
<input type="password">

Parameters & Attributes

NameTypeDescription
typeliteral passwordSelects the password input state.
namestringProvides an element-specific name: a form field key, radio group name, named frame, metadata key, slot name or other defined purpose. Its meaning depends on the element; it is not a unique DOM identifier.
disabledbooleanDisables supported controls or elements. Disabled form controls are generally not focusable, validated or submitted. The exact effect depends on the element; disabled="false" still disables.
formform element IDAssociates an eligible control with a form elsewhere in the same document, overriding an ancestor form where applicable. Does not automatically associate descendants of a fieldset.
valueelement-dependent text or numberDefault value or submitted value depending on type. A file input cannot be prefilled with a path.
autocompleteordered autofill tokens or on/offGives the browser the purpose of a form field or controls autofill. Use meaningful tokens such as email or current-password. A browser may still offer password-manager autofill even with off.
maxlengthnon-negative integerLimits text length in applicable inputs and textareas, measured in UTF-16 code units. It is not a byte limit or a reliable count of user-perceived characters.
minlengthnon-negative integerSets the minimum length of user-entered nonempty text in applicable fields, measured in UTF-16 code units. Add required if an empty value must also be invalid.
patternJavaScript regular expression sourceAdds a whole-value pattern constraint to supported text-like inputs. Modern HTML uses Unicode Sets (v flag) semantics. Do not wrap the pattern in slash delimiters; combine with required to reject empty input.
placeholdershort text hintShows a temporary hint when a supported form field is empty. It disappears during entry and is not a substitute for a persistent accessible label.
readonlybooleanPrevents user editing of eligible inputs and textareas without disabling their normal submission. It does not apply to every control type, and scripts can still alter the value.
requiredbooleanMakes supported form controls subject to a nonempty or selected-value constraint. Radio-group and checkbox behavior differs. It does not perform server-side validation.
sizepositive integerOn applicable text inputs, suggests width in characters; on select, specifies a visible option count. It does not constrain the text length or number of choices.

Return Value

HTMLInputElement

Void form-associated element; no child content. The DOM value and form-submission behavior depend on the input state.

Working Example

Example Snippethtml
<label>  Password  <input type="password" name="password" autocomplete="current-password"></label>
HTML Reference