References

Beginner-friendly references for web development, with live, editable examples.

The HTML autocomplete attribute

Attribute All modern browsers Updated
Quick answer

The HTML autocomplete attribute hints whether and how the browser should autofill the field. It is used on the <form> element and form controls such as <input>, <textarea> and <select>.

Overview

The autocomplete attribute hints whether and how the browser should autofill the field. It applies to the <form> element and form controls such as <input>, <textarea> and <select>.

Specific tokens (like autocomplete="current-password" or one-time-code) help password managers and improve UX. Use off sparingly — it often degrades the experience.

Syntax

<input type="email" autocomplete="email">

Values

Value
on | off — or a specific token such as email, name, current-password, one-time-code.

Example

Live example
<input type="email" autocomplete="email" placeholder="you@example.com" style="padding:8px;">

Best practices

  • Give every control a <label> so it has an accessible name.
  • Treat client-side constraints as a convenience — always validate again on the server, since they can be bypassed.
  • Choose the most specific input type so users get the right on-screen keyboard and built-in checks.
  • Keep the submitted name and value meaningful for whatever processes the form.

Frequently asked questions

What does the autocomplete attribute do?
Controls browser autofill for a field.
Are HTML form attributes enough for validation?
They give instant feedback, but client-side checks can be bypassed, so always validate on the server too.
Do form controls still need a label?
Yes. Every control needs a <label> for an accessible name, whatever attributes you set.
Which elements use the autocomplete attribute?
It is an element-specific attribute, used on form controls such as <input>, <select> and <textarea>.