HTML Autocomplete Tokens and Input Hints
Describe the purpose of a field
autocomplete describes the kind of information a browser may fill. Use given-name, family-name and email for the matching personal details. A token is a hint, not a guarantee that the browser will offer or fill a value.
<label> First name <input name="first" autocomplete="given-name"></label><label> Email <input type="email" name="email" autocomplete="email"></label>The fields declare two distinct autofill purposes.
Distinguish repeated address groups
Use ordered tokens such as shipping postal-code and billing postal-code to distinguish purposes; a section-* token can come first to identify a distinct group. For passwords use current-password at sign-in and new-password for setting a new password. Browsers may ignore off for login credentials.
<label> Shipping postal code <input name="ship" autocomplete="section-order shipping postal-code"></label><label> Billing postal code <input name="bill" autocomplete="section-order billing postal-code"></label>The fields distinguish shipping and billing postal codes without requiring different input types.
Choose keyboard and enter-key hints
inputmode hints at a virtual keyboard layout, and enterkeyhint suggests the enter-key label or icon. Neither sets a validation rule or changes submission behavior by itself. For a numeric access code use text, inputmode=numeric and a pattern if digits must be enforced.
<label> Code <input name="code" inputmode="numeric" enterkeyhint="done" pattern="[0-9]{4}" value="ABCD"></label>The hints are numeric and done; ABCD still fails because of pattern, not inputmode.
Common mistakes and practice
Use correct semantic input types as well as hints. Autofill depends on browser settings and saved information. Test touch keyboards and password managers on target devices; DOM properties alone cannot show what UI appears.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
HTML Autocomplete Tokens and Input Hints — Knowledge Check
Apply the control concepts taught in this lesson.
Which token describes a sign-in password?
Which token order is appropriate?
What does inputmode="numeric" do?
What does enterkeyhint="done" change by itself?
Is autocomplete="off" guaranteed to disable login autofill?