VOOZH about

URL: https://www.geeksforgeeks.org/html/html-form-autocomplete-attribute/

⇱ HTML < form> autocomplete Attribute - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

HTML < form> autocomplete Attribute

Last Updated : 23 May, 2026

The HTML <form> autocomplete attribute allows the browser to automatically fill the form fields based on previous user inputs.

  • Used to save time by reusing data like names, emails, and addresses.
  • It can be turned "on" or "off" depending on the field's requirements.

Syntax

<form autocomplete="on|off">
  • on: It has a default value. It specifies that autocomplete is enabled.
  • off: It specifies that the autocomplete is disabled.
  • The autocomplete="on" attribute is used to allow the browser to automatically fill in values for the form fields based on previously entered data.
  • When autocomplete is enabled, browsers try to predict and offer values for the name, email, or other fields.

Example of HTML <form> autocomplete Attribute

1. Basic Form with Autocomplete Enabled

  • The autocomplete="on" attribute enables the browser to suggest previously entered values for the username and email fields.
  • This feature enhances user experience by reducing the need to re-enter information.

2. Form with Specific Autocomplete Values

  • The autocomplete="on" attribute enables autocomplete for the entire form.
  • Specific autocomplete values like username, email, and new-password are set on individual input fields to guide the browser in providing appropriate suggestions.

Best Practices for HTML <form> Autocomplete Attribute

  • Use autocomplete="on" to enhance user experience by auto-filling known data.
  • Set specific autocomplete values (e.g., username, email) for better browser suggestions.
  • Disable autocomplete (autocomplete="off") only for sensitive or secure fields like OTPs.
Comment
Article Tags: