New in HTML5.

<input autocomplete=””>

Attribute of
<input> HTML Tag
What does <input autocomplete=""> do?
Specifies whether the browser should attempt to automatically complete the input based on user inputs to similar fields.

Code Example

<form>
 <label for="email">Email Address</label><br>
 <input type="email" name="email" id="email" autocomplete="on">
</form>

New(ish) in HTML5

The autocomplete attribute was introduced as an unofficial HTML feature in Microsoft’s Internet Explorer, and was adopted by a number of other browsers. So there has been wide support for it for a long time, although its exact behavior wasn’t standardized. With HTML5, the autocomplete attribute is an official part of the specification.

autocomplete vs. list & <datalist>

The autocomplete attribute asks the browser to attempt autocompletion, based on user history. This is useful for personal details like name and email address — things the user is likely to have types into similar input fields on other web sites. The autocomplete feature is not able to provide the browser with a list of site-specific autocomplete options. For autocomplete behavior with site-specific suggestions, use the list attribute with the <datalist> element.

Deliberately “broken”

All the major browsers ignore the autocomplete="off" value for certain types of input fields. Internet Explorer and Edge ignore it for all password fields. Firefox ignores it for any field in a login form. Chrome ignores it any time the user has elected to let the browser remember form data. Safari ignores it for username, email, and password fields. Ignoring the autocomplete="off" value is done to enhance usability, and gve the user more control over autocomplete behavior. As a UX designer, you should follow their lead and use autocomplete="off" sparingly. There are are very few use cases in normal forms where it really makes sense to disallow autocomplete. In some complex apps, it makes sense to avoid accidental inputs, but with most standard forms there really is no reason for it.

Autocomplete and name

Browsers use the name attribute in order to figure out what type of information an input field is asking for. So use standard, meaningful values for name. If you are asking for an address, use names like:

  • address-1
  • address-2
  • city
  • state or province
  • zip or postal-code

Don’t use clever or oddly specific names, as that makes it harder for the browser to provide autocomplete suggestions, and it can even lead to the browser trying to fill in the wrong values into the wrong inputs. (Have you ever had your browser fill your phone number into the zip code field? That was the fault of bad naming.)

Values of the autocomplete Attribute

Value NameNotes
offTurns autocomplete off.
onTurns autocomplete on.

All Attributes of input Element

Attribute nameValuesNotes
stepSpecifies the interval between valid values in a number-based input.
requiredSpecifies that the input field is required; disallows form submission and alerts the user if the required field is empty.
placeholderSpecifies placeholder text in a text-based input.
patternSpecifies a regular expression against which to validate the value of the input.
multipleAllows the user to enter multiple values into a file upload or email input.
minSpecifies a minimum value for number and date input fields.
maxSpecifies a maximum value for number and date input fields.
listSpecifies the id of a <datalist> element which provides a list of autocomplete suggestions for the input field.
heightSpecifies the height of an image input.
formtargetSpecifies the browsing context in which to open the response from the server after form submission. For use only on input types of “submit” or “image”.
formmethodSpecifies the HTTP method (GET or POST) to be used when the form data is submitted to the server. Only for use on input types of “submit” or “image”.
formenctypeSpecifies how form data should be submitted to the server. Only for use on input types “submit” and “image”.
formactionSpecifies the URL for form submission. Can only be used for type=”submit” and type=”image”.
formSpecifies a form to which the input field belongs.
autofocusSpecifies that the input field should be in focus immediately upon page load.
accesskeyDefines a keyboard shortcut for the element.
autocompleteoff
on
Specifies whether the browser should attempt to automatically complete the input based on user inputs to similar fields.
borderWas used to specify a border on an input. Deprecated. Use CSS instead.
checkedSpecifies whether a checkbox or radio button form input should be checked by default.
disabledDisables the input field.
maxlengthSpecifies the maximum number of characters that can be entered in a text-type input.
languageWas used to indicate the scripting language used for events triggered by the input.
nameSpecifies the name of an input element. The name and value of each input element are included in the HTTP request when the form is submitted.
sizeSpecifies the width of the input in characters.
srcDefines the source URL for an image input.
typebutton
checkbox
file
hidden
image
password
radio
reset
submit
text
Defines the input type.
valueDefines an initial value or default selection for an input field.
Adam is a technical writer who specializes in developer documentation and tutorials.

Browser Support for autocomplete

AllAllAllAllAllAll