MyInternships.in

HTML Attributes

HTML <form> autocomplete Attribute

The autocomplete attribute on a <form> sets the default autofill behaviour for all fields inside it. Individual fields can still override that default.


The <form> autocomplete Attribute

When placed on the <form> element, autocomplete defines the default for every input, textarea and select in the form. Individual fields can still override this by setting their own autocomplete attribute, giving you form-wide control with per-field exceptions.

Syntax

ℹ️

Syntax: <form autocomplete="on"> or <form autocomplete="off">. The default is on when the attribute is not specified.

The basic pattern
Example
<form autocomplete="off"> ... </form>

Example

Run the example. Autofill is turned off for the whole form, but the email field re-enables it for itself.

Form-wide off with one field re-enabled
Example
<!DOCTYPE html>
<html>
  <body>
    <form autocomplete="off">
      <label for="code">One-time code</label><br>
      <input type="text" id="code" name="code" placeholder="Do not autofill"><br><br>

      <label for="mail">Email</label><br>
      <input type="email" id="mail" name="email" autocomplete="email"
             placeholder="Autofill allowed here"><br><br>

      <button type="submit">Continue</button>
    </form>
  </body>
</html>

Attribute Values

ValueDescription
onFields may be autofilled by the browser (the default)
offThe browser should not autofill fields in this form by default
⚠️

Setting autocomplete="off" is only a hint. Browsers may ignore it for login and password fields to keep password managers working, so never rely on it for security.

Key Takeaways

  • autocomplete on a <form> sets the default for all its fields.
  • Individual inputs can override the form-level value.
  • The default is on when the attribute is absent.
  • off is only a hint and may be ignored for logins.
  • Never rely on off for security or privacy.

Related HTML Topics

Keep learning with these closely related tutorials.

Ready to use your HTML skills?

Find web development internships and fresher jobs across India.

Browse Web Dev Internships