HTML Password Fields and Autofill Guidance
A masked text control
type="password" hides typed characters visually in the usual browser interface. The value remains a string accessible to scripts on the page and to the form submission process. It is not encrypted by the input type.
<label> Practice password <input type="password" name="practice"></label>Type only fictional characters; the input masks their display.
Sign-in autofill
Use autocomplete="username" for a sign-in identifier and current-password for an existing password. These tokens guide browsers and password managers; they do not perform sign-in. POST is appropriate for a credential request, but HTTPS is still required.
<form action="/session" method="post"> <label> Account <input name="user" autocomplete="username"> </label> <label> Password <input type="password" name="password" autocomplete="current-password"> </label></form>This is a sign-in structure only; no authentication endpoint is implemented.
Create a new password
Use new-password for creating or changing a password. required prevents an empty ordinary submission; minlength can express a local length rule for user-entered text. The example length is illustrative, not a complete security recommendation.
<label> New password <input type="password" name="newPassword" autocomplete="new-password" required minlength="12"></label>The field is initially missing a required value and signals new-password autofill.
Common mistakes and practice
Never enter real credentials into tutorial previews. Masking only changes the visual display, not the underlying value. Use HTTPS and a server authentication implementation with appropriate password hashing; do not log passwords. Allow password managers and paste. A client length rule is not a complete password policy.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
HTML Password Fields and Autofill Guidance — Knowledge Check
Apply the form-control concepts from this lesson.
What does type="password" primarily change?
Which token describes an existing sign-in password?
What is needed in addition to POST to protect credentials in transit?
Which autocomplete token is appropriate when creating a new password?
Does masking a password field encrypt its value?