Autofill is the biggest single accessibility and speed improvement most forms can get for free — and most forms get it wrong: fields without autocomplete, invented values like autocomplete="email-address", autocomplete="off" on a login, or a shipping and billing address that browsers fill with the same data because nothing tells them apart.
The autocomplete attribute takes a defined set of tokens from the HTML specification. Correct tokens let browsers and password managers fill fields accurately, let people with motor and cognitive disabilities avoid retyping personal data, and satisfy WCAG 2.1’s “Identify Input Purpose” criterion (1.3.5, AA). This page, part of keyboard navigation patterns, lists the tokens forms need and how to combine them.
Context and prerequisites
The attribute’s grammar, in order:
- Optional section:
section-<name>— groups fields that belong together when a page has several of the same kind (two addresses in different blocks). - Optional group:
shippingorbilling— distinguishes addresses and contact details by purpose. - Optional contact type (for contact fields):
home,work,mobile,fax,pager. - The field name token (required):
name,email,tel,street-address,postal-code,cc-number,current-password, … - Optional
webauthn— appended for passkey conditional UI on username or password fields.
Example: autocomplete="shipping postal-code", autocomplete="work email", autocomplete="section-guest2 shipping address-line1".
autocomplete="off" asks the browser not to store or suggest; browsers largely ignore it for login fields, and it should be used only for fields where suggestions are genuinely wrong (a one-time search box, a CAPTCHA answer).
The core pattern: a checkout form with correct tokens
<form>
<fieldset>
<legend>Contact details</legend>
<label for="c-name">Full name</label>
<input id="c-name" name="name" autocomplete="name">
<label for="c-email">Email address</label>
<input id="c-email" name="email" type="email" autocomplete="email">
<label for="c-tel">Mobile number</label>
<input id="c-tel" name="tel" type="tel" autocomplete="mobile tel">
</fieldset>
<fieldset>
<legend>Delivery address</legend>
<label for="s-line1">Address line 1</label>
<input id="s-line1" name="ship-line1" autocomplete="shipping address-line1">
<label for="s-line2">Address line 2 (optional)</label>
<input id="s-line2" name="ship-line2" autocomplete="shipping address-line2">
<label for="s-town">Town or city</label>
<input id="s-town" name="ship-town" autocomplete="shipping address-level2">
<label for="s-postcode">Postcode</label>
<input id="s-postcode" name="ship-postcode" autocomplete="shipping postal-code">
<label for="s-country">Country</label>
<select id="s-country" name="ship-country" autocomplete="shipping country"><!-- ISO codes as values --></select>
</fieldset>
<fieldset>
<legend>Payment</legend>
<label for="cc-name">Name on card</label>
<input id="cc-name" name="cc-name" autocomplete="cc-name">
<label for="cc-number">Card number</label>
<input id="cc-number" name="cc-number" inputmode="numeric" autocomplete="cc-number">
<label for="cc-exp">Expiry date (MM/YY)</label>
<input id="cc-exp" name="cc-exp" inputmode="numeric" autocomplete="cc-exp">
<label for="cc-csc">Security code</label>
<input id="cc-csc" name="cc-csc" inputmode="numeric" autocomplete="cc-csc">
</fieldset>
</form>
Step-by-step walkthrough
- Give every personal-data field a token. WCAG 1.3.5 applies to fields collecting information about the user; a correct token is how you meet it.
- Use the exact spec tokens.
email, note-mailoremailAddress;postal-code, notzip. Unknown values are ignored as if no attribute were present. - Match field granularity to the token. One “Full name” field gets
name; separate fields getgiven-nameandfamily-name. A single address textarea getsstreet-address; separate lines getaddress-line1/address-line2. - Prefix with
shipping/billingwhen both appear. Otherwise browsers may fill both blocks with the same saved address. - Use
section-*for repeated blocks. Multiple guests’ names on one page:section-guest1 name,section-guest2 name. - Pair credential tokens with the right input types.
username+current-passwordon login;new-passwordon sign-up and password change, which triggers password generation. Reconcile filled values at submit, as in handling browser autofill in controlled inputs.
Why autofill is an accessibility feature
For a person using a switch, a head pointer or voice control, every character typed costs time and effort; filling a full address by hand can take minutes. For people with memory or cognitive impairments, recalling a postcode or card expiry may be genuinely hard. Correct autocomplete tokens turn those minutes into one selection from the browser’s suggestion list. They also allow assistive technologies to present fields with familiar icons or symbols — the “input purpose” WCAG 1.3.5 is named for. None of this requires JavaScript or design changes; it is one attribute per field, and it is one of the highest-value accessibility fixes available in most forms.
Designing fields so autofill has something to match
Tokens only help when the form’s structure matches the data browsers store. Browsers keep addresses as a small set of parts — lines, town, region, postcode, country — and names as given, additional and family names. A form that asks for “House number” and “Street” separately, or “First name” and “Surname” when the audience includes people with a single name, forces the browser to guess, and it often guesses wrong or not at all. Where you can, follow the stored shape: address lines rather than house number and street, a single “Full name” field unless you genuinely need the parts, and a country select whose values are ISO codes.
When business requirements do demand unusual granularity, keep autofill working for the fields that do match and accept that the rest will be typed. Do not reuse a token on a field that means something different — marking “House name” as address-line1 fills it with a street address, which is worse than filling nothing.
Order matters too. Browsers fill a whole group at once when the user selects a saved address, and they use the relative position of fields as a hint. Grouping all address fields together, in the conventional order, inside one fieldset with a clear legend, makes a single autofill selection complete the whole block, which is the experience that saves users the most effort.
Finally, test autofill in the browsers your users have. Save a test profile with a name, email, phone and two addresses in Chrome, Safari and Firefox, fill the form from each, and check that every field receives the right part — and that shipping and billing blocks receive the addresses you chose for them.
Failure modes and edge cases
1. autocomplete="off" on login forms
Browsers ignore it for credentials to protect password-manager users, and where it is honoured it pushes people toward weak, memorable passwords. Leave credential fields fillable.
2. Invented tokens
autocomplete="address" or "postcode" do nothing. Validators such as the W3C HTML checker and axe flag invalid tokens; include one in CI.
3. Hidden fields that get filled
Browsers may fill hidden address fields (address line 2, company) that your form hides behind a toggle. Decide what happens to hidden-but-filled values with the relevance rules from what happens to errors when a field is hidden.
4. Country as free text
Browsers fill country with an ISO code and country-name with a localised name. Use a select with ISO codes as values and autocomplete="country", or accept the name with country-name and normalise server-side.
5. Custom components
Autocomplete only works on native form controls the browser recognises. A custom select or a web component must render a native input (or be form-associated with an inner input carrying the token) to be fillable, as in building Lit form controls with ElementInternals.
Verification checklist
Frequently Asked Questions
Does autocomplete affect validation?
No — it only guides filling. Autofilled values still need validation, and some arrive without the input events your code expects; reconcile at submit.
Should the name attribute match the token?
It helps browsers’ heuristics but is not required; the autocomplete token is authoritative. Use clear, stable name values for your server and correct tokens for autofill.
What about passkeys?
Add webauthn to the username field’s token (autocomplete="username webauthn") to enable conditional passkey UI, where the browser offers saved passkeys in the autofill menu. Keep the password field for users without passkeys.