How to enable autocomplete in a input in HTML
In this article, we’ll learn how to enable autocomplete in a input in HTML, and thus let the page make suggestions to the user of what can be auto-completed.
Hey you programmer, okay? Let’s learn something new!
As the incoming of HTML5 in 2014, several features have been added and are still in progress
One of them was the auto-complete option for form inputs, which is premised on helping users
And this is easily triggered by the autocomplete attribute on inputs, it’s the only thing we need to do, check it out:
<form> <p>Fill the form:</p> <div> <input type="email" name="email" placeholder="Type your email" autocomplete> </div> <div> <input type="submit" value="Send"> </div> </form>
This is the return on the screen:
We have all the options we’ve already used in an email field, according to this example, to choose
Of course, we can use it with other types of values, not just email
So with the autocomplete attribute we were able to activate autocomplete in our form input
Another important idea that we can extract from this example is the use of HTML attributes
One that helps the user a lot too is the placeholder
This is to give a hint as to what the user must fill in a certain field of the form
According to the complexity of the data that we need the user to fill, it’s really a hand on the wheel
And we can also use others like required, which makes the field mandatory.
Anyway, the world of attributes is huge, I suggest you do some research
In this article, we learned how easy it is to enable autocomplete in a input in HTML.
We just need to add the autocomplete attribute to the desired input and that’s how the suggestions will be made.
Want to learn more about HTML? Click here!