HTML Attributes
HTML <input> autocomplete Attribute
The autocomplete attribute controls whether the browser may automatically fill in an input's value. Meaningful tokens help browsers autofill accurately.
The <input> autocomplete Attribute
The autocomplete attribute tells the browser whether, and how, it should help fill in a form field using previously stored values. On <input>, <textarea> and <select>, it accepts on, off, or specific tokens that describe the expected data so the browser can autofill accurately.
Syntax
Syntax: <input autocomplete="token">. The value is on, off, or a standard token such as email, name, tel or street-address.
<input type="email" name="email" autocomplete="email">Example
Run the example and focus a field — your browser may offer to autofill it based on the token you provided.
<!DOCTYPE html>
<html>
<body>
<form>
<label for="n">Full name</label><br>
<input type="text" id="n" name="fullname" autocomplete="name"><br><br>
<label for="e">Email</label><br>
<input type="email" id="e" name="email" autocomplete="email"><br><br>
<label for="p">New password</label><br>
<input type="password" id="p" name="new-pass" autocomplete="new-password"><br><br>
<button type="submit">Save</button>
</form>
</body>
</html>Attribute Values
| Value | Description |
|---|---|
| on | Allow the browser to autofill this field (default behaviour) |
| off | Disable autofill, e.g. for sensitive or one-off fields |
| name | Full name |
| Email address | |
| tel | Telephone number |
| new-password | A new password, hinting password managers to suggest one |
Use meaningful tokens rather than off wherever possible. Correct tokens improve accessibility and speed up form completion for users on mobile devices.
Key Takeaways
- autocomplete controls whether and how a field is autofilled.
- It works on <input>, <textarea> and <select>.
- Prefer descriptive tokens like name, email and tel over off.
- Use new-password to help password managers suggest strong passwords.
- Good tokens speed up form filling, especially on mobile.
