Autocomplete attributes: faster checkout forms on phones
Short answer: The autocomplete attribute tells the browser exactly what each field wants, so it can fill a whole checkout form from a saved address or card in one tap. Add the right token to every field (name, email, street-address, postal-code, cc-number and so on), pair it with the right input type, and keep stable name and id values. Then test on a real phone, because autofill fails silently.
On a desktop, a missing autocomplete value is a mild annoyance. On a phone, it means a customer pecking out their ZIP code with one thumb while holding a coffee. Many checkout drop-offs have nothing to do with price; the form simply felt like work.
What the attribute actually does
MDN's autocomplete reference describes it as a hint to the browser about how, or whether, to prefill a control. The value is off, on, or a list of space-separated tokens. on lets the browser guess. A specific token removes the guessing.
Tokens can also carry a grouping prefix. shipping street-address and billing postal-code tell the browser which saved address a field belongs to, and a section- prefix separates two sets of the same fields on one page (two recipients, for example).
MDN adds a practical note: browsers may only offer autofill when fields have a name or id, sit inside a <form>, and that form has a submit button. Forms built from loose divs and a JavaScript click handler are the usual reason autofill "just doesn't work here".
Step 1: Map every field to a token
Go through your checkout, account and contact forms one field at a time.
| Field | autocomplete value |
Input type / mode | Notes |
|---|---|---|---|
| Full name | name |
type="text" |
web.dev recommends one name field unless you really need parts |
| First / last name (if split) | given-name, family-name |
type="text" |
Skip a title/prefix field |
email (sign-in: username) |
type="email" |
See Step 3 for login forms | |
| Phone | tel |
type="tel" |
Split parts have their own tokens; one field is simpler |
| Street address | street-address (textarea) or address-line1, address-line2 |
textarea or type="text" |
Use one approach, not both |
| City | address-level2 |
type="text" |
MDN's term for the second administrative level |
| State | address-level1 |
select or text |
|
| ZIP code | postal-code |
type="text", inputmode="numeric" if US-only |
Don't use type="number" |
| Country | country or country-name |
select |
|
| Card number | cc-number |
type="text", inputmode="numeric" |
One input, not four boxes |
| Name on card | cc-name |
type="text" |
|
| Expiry | cc-exp (or cc-exp-month + cc-exp-year) |
text or selects | Avoid custom date widgets |
| Security code | cc-csc |
type="text", inputmode="numeric" |
|
| New password | new-password |
type="password" |
Sign-up and reset forms |
| Current password | current-password |
type="password" |
Sign-in form |
| Text-message code | one-time-code |
type="text", inputmode="numeric" |
Lets the phone offer the code |
Why type="number" keeps showing up as a problem
web.dev's address and payment form guide warns against type="number" for card, phone and account numbers: it adds increment arrows that make no sense for an identifier. Use type="text" with inputmode="numeric" for a number pad, and type="tel" for phone numbers.
Step 2: Payment fields
The same guide lists cc-number, cc-name, cc-exp (or the split month and year tokens) and cc-csc as the values to add, and makes two points that small stores often miss:
- Don't add a card-type dropdown. The brand can be inferred from the number.
- Avoid custom elements for expiry dates if they break autofill.
If your card fields live inside a payment provider's hosted iframe, the provider controls these attributes, not you. Your job then is the address and contact fields around it.
Step 3: Sign-up, sign-in and one-time codes
Account forms trip up password managers more than anything else. web.dev's sign-in form guide recommends:
autocomplete="username"on the email field of a sign-in form, even though the input istype="email", because password managers recognizeusername.autocomplete="new-password"on sign-up and reset forms, so the browser offers a strong password and doesn't fill an old one.autocomplete="current-password"on the sign-in password.- Stable
nameandidvalues that don't change between deployments.
For codes sent by text message, web.dev's SMS OTP article gives a three-part checklist: an input with type="text", inputmode="numeric" and autocomplete="one-time-code"; a last line in the SMS in the form @your-domain #123456; and the WebOTP API where supported. The plain input is the part that works everywhere.
Step 4: Test on real devices
Lab tools won't tell you whether autofill worked. Do this instead:
- Save a test address and a test card in Chrome on Android and in Safari on an iPhone.
- Open the checkout in a normal (not private) window and tap the first field.
- Check that one tap fills every field it should, including state and country.
- Submit, then reload the page and repeat. Fields that only fill the first time often have changing
idvalues. - Try the sign-up form and confirm the browser suggests a strong password.
- Send yourself a sign-in code and see whether the keyboard offers it.
Common ways autofill breaks
autocomplete="off"everywhere. Often added years ago to stop a browser filling the wrong thing. MDN notes that in most modern browsers it won't stop password managers anyway; it mostly just slows real customers down.- Fields outside a
<form>or forms with no submit button. - Generated IDs from a page builder that change on every build.
- Separate house-number and street fields. web.dev points out that many addresses don't fit that split, and incomplete data breaks autofill.
- Required fields that don't apply, such as forcing a field some addresses never have.
- Mixing
street-addressandaddress-line1in the same form.
A hypothetical before-and-after
Imagine a hypothetical candle shop whose checkout uses split house-number fields, a title dropdown and an unlabeled ZIP box with type="number". After the change it has one name field, one street-address textarea, a postal-code field with a numeric keyboard, and proper card tokens. Nothing about the design changed; the form just stopped arguing with the phone.
FAQ
Does autocomplete help SEO?
Not directly. It's a usability fix on the forms where people buy or sign up, which is where it pays off.
Should I ever use autocomplete="off"?
For a field where a saved value would be wrong, such as a gift message or a one-off reference number, it's reasonable. For contact, address or payment fields, use the specific token instead.
Do Shopify or WooCommerce checkouts need this work?
Hosted checkouts usually ship with these values set. Custom forms, quote forms, booking widgets and anything a page builder generated are where gaps tend to appear, so test those first.
Why does Safari fill some fields and not others?
Usually a missing token, a field outside the form, or two fields claiming the same token. Inspect each field and compare it with the table above.
When a checkout looks fine but feels slow to fill on a phone, ask us to audit the form field by field.