Open In App

HTML autocomplete Attribute

Improve
Improve
Like Article
Like
Save
Share
Report

The HTML autocomplete Attribute is used to specify whether the input field autocompleted would be on or off. When the autocomplete attribute is set to on the browser will automatically complete the values based on what the user entered before. It works with input fields such as text, search, URL, email, password, date pickers, range, and color.

Supported Tags

Syntax:

<element autocomplete="on | off"> 

Attribute Values

Value

Description

on

on: It has a default value. It specifies that autocomplete is enabled.

off

It specifies that the autocomplete is disabled.

HTML autocomplete Attribute Examples

Example 1: In this example the HTML form disables autocomplete for the input field “text_id” within the “myGeeks” form, enhancing user privacy and control over data input.

HTML




<!DOCTYPE html>
<html>
    <body>
        <h1>Welcome to GeeksforGeeks</h1>
        <form id="myGeeks">
            <input
                type="text"
                autocomplete="off"
                id="text_id"
                name="fname"
            />
            <input type="submit" />
        </form>
    </body>
</html>


Output:

Setting the autocomplete attribute value to off

Example2: In this example the HTML form includes an input field with autocomplete enabled, enhancing user experience by suggesting previously entered values, increasing efficiency during data entry.

HTML




<!DOCTYPE html>
<html>
    <head>
        <title>HTML autocomplete Attribute</title>
    </head>
 
    <body>
        <h1>GeeksforGeeks</h1>
        <h2>HTML autocomplete Attribute</h2>
        <form id="myGeeks">
            <input
                type="text"
                autocomplete="on"
                id="text_id"
                name="fname"
            />
 
            <input type="submit" />
        </form>
    </body>
</html>


Output:

autocomplete attribute Example output

HTML autocomplete Attribute Use Cases

1.What is the significance of adding autocomplete attribute in HTML Form ?

The autocomplete attribute in HTML forms enhances user experience by suggesting previously entered values, speeding up data entry and reducing errors.

2.How to turn on/off form autocompletion in HTML ?

To turn on form autocompletion, set the autocomplete attribute to “on” for the form or individual input fields. To turn it off, set it to “off”.

Supported Browsers



Last Updated : 07 Mar, 2024
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads