HTML autocomplete Attribute
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
- HTML form autocomplete Attribute: It is used to specify that the form has autocompleted on or off value.
- HTML input autocomplete Attribute: It is used to specify that the input has autocompleted on or off value.
- HTML select autocomplete Attribute: It is used to specify that the select has autocompleted on or off value.
- HTML textarea autocomplete Attribute: It is used to specify that the textarea has autocompleted on or off value.
- HTML fieldset autocomplete Attribute: It is used to specify that the fieldset has autocompleted on or off value.
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 “myBeginner” form, enhancing user privacy and control over data input.
HTML
<!DOCTYPE html> < html > < body > < h1 >Welcome to w3wiki</ h1 > < form id = "myBeginner" > < input type = "text" autocomplete = "off" id = "text_id" name = "fname" /> < input type = "submit" /> </ form > </ body > </ html > |
Output:
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 >w3wiki</ h1 > < h2 >HTML autocomplete Attribute</ h2 > < form id = "myBeginner" > < input type = "text" autocomplete = "on" id = "text_id" name = "fname" /> < input type = "submit" /> </ form > </ body > </ html > |
Output:
HTML autocomplete Attribute Use Cases
The autocomplete attribute in HTML forms enhances user experience by suggesting previously entered values, speeding up data entry and reducing errors.
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”.
Contact Us