How to autocomplete the values for Name or Full Name fields in an input HTML element using HTML?

December 14, 2022 - 2 min read

To autocomplete the value for the Name, Full Name, or name fields in an input HTML element, you can add the attribute called autocomplete with the value of name to the input HTML element using HTML.

TL;DR

<!-- 
  A simple webpage with an `input` HTML
  element with autocomplete for the name 
-->
<html>
  <body>
    <label for="fullName">Full Name</label>
    <input type="text" id="fullName" autocomplete="name" />
  </body>
</html>

For example, let's say we have an input HTML element to accept the full name of the user.

The HTML for that would look something like this,

<!-- A simple webpage with an `input` HTML element -->
<html>
  <body>
    <label for="fullName">Full Name</label>
    <input type="text" id="fullName" />
  </body>
</html>

A visual representation of the webpage is shown below,

As you can see from the above GIF that when clicking on the input HTML element, the autocomplete is not working for the Full Name field.

To activate the autocomplete feature, we have to add the autocomplete attribute with the value of name. The name value refers that we need to autocomplete the full name of the user.

It can be done like this,

<!-- 
  A simple webpage with an `input` HTML
  element with autocomplete for the name 
-->
<html>
  <body>
    <label for="fullName">Full Name</label>
    <input type="text" id="fullName" autocomplete="name" />
  </body>
</html>

Now the webpage looks like this,

As you can see from the above GIF now when clicking on the input HTML element, a autocomplete dropdown is shown to the user where they can select the name they want.

We have successfully added the autocomplete feature and added the value for the Full Name input HTML element using HTML. Yay 🥳!

See the above code live in the codesandbox.

That's all 😃.