The autocomplete attribute on <input>, <select>, and <textarea> declares the field's semantic purpose. Browsers use it to offer autofill from saved profile data; password managers use it to identify which fields to fill or save; assistive technology uses it (per WCAG 1.3.5) to render simplified or specialized inputs.
The value is a token from a defined vocabulary, not a free-form hint. Common values:
- Identity / contact:
name,given-name,family-name,email,tel,street-address,postal-code,country-name,address-level1(state/province),address-level2(city) - Authentication:
username,current-password(for login),new-password(for registration / change-password) - Payment:
cc-name,cc-number,cc-exp,cc-exp-month,cc-exp-year,cc-csc,cc-type
Common bugs:
- Using
autocomplete="password"instead of the specificcurrent-password/new-password-- the deprecated value is silently ignored. - Setting
autocomplete="off"on payment / login forms -- browsers and managers respect this and disable autofill, hurting conversion. - Login forms where the username field has no
autocomplete=username(or=email) -- the password manager can't identify which field is the username and silently skips autofill on the whole form.
Per WCAG 1.3.5 (Identify Input Purpose, AA), inputs whose purpose maps to a Common Input Purpose value MUST declare it via autocomplete=. This is one of the highest-impact accessibility wins on a typical form.