Input Types
HTML input type="password"
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
| Name | Type | Description |
|---|---|---|
| type | literal password | Selects the password input state. |
| name | string | Provides 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. |
| disabled | boolean | Disables 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. |
| form | form element ID | Associates 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. |
| value | element-dependent text or number | Default value or submitted value depending on type. A file input cannot be prefilled with a path. |
| autocomplete | ordered autofill tokens or on/off | Gives 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. |
| maxlength | non-negative integer | Limits 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. |
| minlength | non-negative integer | Sets 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. |
| pattern | JavaScript regular expression source | Adds 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. |
| placeholder | short text hint | Shows a temporary hint when a supported form field is empty. It disappears during entry and is not a substitute for a persistent accessible label. |
| readonly | boolean | Prevents 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. |
| required | boolean | Makes supported form controls subject to a nonempty or selected-value constraint. Radio-group and checkbox behavior differs. It does not perform server-side validation. |
| size | positive integer | On 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>