autocomplete

The autocomplete attribute in HTML enables input fields to suggest previously entered values, streamlining the form-filling process.

autocomplete attribute

The autocomplete attribute in HTML helps users fill out forms faster by suggesting previously entered values. It can be applied to forms or specific fields like <input>, <textarea>, and <select>. The value of the attribute specifies the type of information expected, like email, name, or <address>, guiding the browser's suggestions.

Syntax

index.html
<input autocomplete="on | off | <token-list>" />

Example



index.html
<form autocomplete="on">
  <div>
    <label for="name">Your Name:</label>
    <input type="text" name="name" id="name">
    </div>
    <div>
    <label for="phone">Phone Number:</label>
    <input type="number" id="phone" name="phone">
    <br>
    </div><br>
    <input type="submit" value="Send">
</form>
You can enable autocomplete for the entire form while disabling it for specific input fields, or vice versa.

Key Points

Elements: Works with <input>, <textarea>, <select>, and <form> elements elements.

Purpose: Tells the browser to suggest information and what type of input is expected.

Basic Values

  • on: Allows the browser to autofill the field with user data.
  • off: Disables autofill for the field.

Applies To

The autocomplete attribute can be applied to the following HTML elements.

See also

Conclusion

The autocomplete attribute enhances user experience by suggesting previously entered information in form fields. It can be applied to various form elements to streamline the input process. This feature improves accessibility and efficiency, making form-filling faster and more convenient.