Module 11: Advanced HTML Forms and Validation
autocomplete, inputmode, and Placeholder
Help browsers and mobile keyboards offer useful input assistance without hiding the field’s purpose.
The autocomplete attribute tells the browser what kind of information a control expects. It can help browsers and password managers fill forms accurately.
<label for="name">Full name</label>
<input id="name" name="name" autocomplete="name">
<label for="email">Email</label>
<input id="email" name="email" type="email" autocomplete="email">
<label for="postal">Postal code</label>
<input id="postal" name="postalCode" autocomplete="postal-code" inputmode="numeric">
Use standard autocomplete tokens that match the information being collected. For account forms, values such as username, current-password, and new-password help password managers distinguish the purpose of fields.
inputmode is a hint about the virtual keyboard. It does not change the type of the control or validate the value. For example, inputmode="numeric" can request a numeric keyboard while keeping a value as text.
A placeholder is a short hint inside an empty control. It is not a replacement for a label, because it disappears when the visitor types and can have low contrast. Put important instructions outside the field and connect them with accessible descriptions when needed.