HTML autocomplete Attribute

The autocomplete attribute on an input element presents the user with previously entered values. Elements that accept this attribute include <input>, <select>, <textarea>, and <form>.

Example

#

An autocomplete attribute on two <input> elements.
Depending on the browser, clicking these fields reveals a dropdown with prior values.





<form action="/tutorial/action.html" >
  <input autocomplete="on" type="text" name="firstname" placeholder="First name"> <br /><br />
  <input autocomplete="on" type="text" name="lastname" placeholder="Last name"> <br /><br />

  <button type="submit">Submit</button>
</form>

For additional details see our HTML input autocomplete Reference.


Using autocomplete

The autocomplete attribute specifies to the browser that input can be autofilled.

When autocomplete is on, the browser provides input values based on previous values the user has entered.

This attribute is available on any element that accepts user input that is either numeric or text.

This includes <textarea>, <select>, and <input> controls of type: text, search, URL, email, password, date pickers, range, and color. The <form> element also supports autocomplete -- it enables autocomplete for all its input elements.

Most browsers intentionally ignore autocomplete="off". In other words, it cannot be turned off.


Syntax

<tagname autocomplete="on | off" >

Values

#

Value Description
on Use autocomplete. This is the default.
off Turn off autocomplete.

Elements that accept autocomplete

These elements accept the autocomplete attribute.

Elements Description
<input> Specifies an input control -- see example above
<select> Creates a dropdown control
<textarea> Creates a multi-line input element
<form> Defines an area with input controls

<select> with autocomplete

A <select> tag with autocomplete turned on.


<form action="/tutorial/action.html">
  <select name="color" autocomplete="on"> 
    <option value="">-- Select Color --</option> 
    <option value="red">Red</option> 
    <option value="blue">Blue</option> 
    <option value="green">Green</option> 
  </select> <br />

  <button type="submit">Submit</button>
</form>

For additional details see our HTML select autocomplete Reference.


<textarea> with autocomplete

A <textarea> tag with autocomplete turned on.



<form action="/tutorial/action.html" >
  <textarea autocomplete="on" name="message" 
            placeholder="Enter message" 
            rows="3" cols="60"></textarea> <br /><br />

  <button type="submit">Submit</button>
</form>

For additional details see our HTML textarea autocomplete Reference.


The <form> autocomplete Attribute

A <form> tag with autocomplete turned on.
This setting enables autocomplete for all its child input controls.

<form action="/tutorial/action.html" autocomplete="on">
  <input type="text" name="firstname" placeholder="First name">
  <input type="text" name="lastname" placeholder="Last name">

  <button type="submit">Submit</button>
</form>

For additional details see our HTML form autocomplete Reference.


Browser support

Here is when autocomplete support started for each browser:

Chrome
1.0 Sep 2008
Firefox
1.0 Sep 2002
IE/Edge
1.0 Aug 1995
Opera
1.0 Jan 2006
Safari
1.0 Jan 2003

You may also like



Guides