Coding Hubs School of AI – Best AI & Full Stack Courses in Delhi NCR | 100% Placement
Limited Offer: Get 50% OFF on AI & Full Stack Courses
📞 Call Now: +91 8448811540
Back to HTML Notes
Topic #728

autocomplete

The autocomplete attribute tells the browser what kind of data a field expects, letting it offer accurate, relevant autofill suggestions from the user's saved information.

Syntax

<input type="email" name="email" autocomplete="email">
<input type="text" name="fname" autocomplete="given-name">

Basic Example

<label for="email">Email</label>
<input type="email" id="email" name="email" autocomplete="email">

Browser output: when the user focuses this field, the browser can suggest previously saved email addresses from its own autofill data — genuinely speeding up form completion.

How It Works

autocomplete uses a set of standardized token values, not arbitrary text — the browser matches the token to the correct category of saved data (name, address, payment info) it already stores for the user.

Important Attributes / Common Values

ValueFor
name, given-name, family-nameFull/first/last name
emailEmail address
telPhone number
current-passwordAn existing password, on a login form
new-passwordA new password, on a signup/change-password form
address-line1, postal-code, countryAddress fields
offExplicitly discourages autofill — use sparingly, see below

Real-World Example

<label for="signup-password">Create a Password</label>
<input type="password" id="signup-password" name="password" autocomplete="new-password" minlength="8">

new-password tells the browser this is a fresh password to potentially generate and remember, not one to autofill from existing saved credentials — an important, specific distinction from a login form's password field.

Common Mistakes

  • Setting autocomplete="off" broadly to "clean up" a form — this actively discourages password managers, which works against good security practice
  • Using the wrong token (like current-password on a signup form), causing the browser to offer a mismatched, confusing autofill suggestion

Best Practices

  • Add correct, specific autocomplete tokens to every relevant field — name, email, address, phone, and password fields especially
  • Reserve autocomplete="off" for genuinely sensitive, non-reusable fields (like a one-time verification code) where autofill would be actively wrong

Accessibility Considerations

Correct autocomplete values are explicitly called out as a WCAG success criterion (1.3.5, "Identify Input Purpose") — this is a genuine, documented accessibility requirement, not just a UX nicety, particularly benefiting users with cognitive or motor disabilities who rely heavily on autofill.

SEO Considerations

No direct ranking effect, though faster, lower-friction forms directly improve real conversion rates.

Browser & Modern HTML Notes

The full list of standardized token values is defined in the HTML spec itself — using a value outside that list simply has no effect, rather than causing an error.

Mini Practice

  1. Add correct autocomplete values to a signup form's name, email, and new-password fields.
  2. Explain, in your own words, the difference between current-password and new-password.

Related HTML Notes

Want to go beyond the notes?

Join Coding Hubs School of AI's HTML course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available
💬 Talk to Advisor
1
WhatsApp

Latest from Our Blog

Insights on AI, Data Science, Full Stack & Career

View All Articles →