πŸŽ‰ We just launched a new HTML course! Get 3 courses with 33% off! πŸŽ‰
How to Build Native HTML Autocomplete Search

How to Build Native HTML Autocomplete Search

Ferenc Almasi β€’ πŸ”„ 2021 April 29 β€’ πŸ“– 1 min read
  • twitter
  • facebook
πŸ“• HTML

To create a native autocomplete search in HTML, you can use the datalist tag with a set of options attached to an inputelement. For example:

<label for="tech">Choose your tech:</label>
<input list="techlist" name="tech" id="tech" />

<datalist id="techlist">
    <option value="HTML">
    <option value="CSS">
    <option value="JS">
</datalist>
autocomplete.html
Copied to clipboard!

Note that the id of the datalist must match the list attribute on an input element.

You can try the behavior with the input below:

Currently, it has partial support on the latest versions of IE and Firefox, while other latest versions of major browsers are well supported.

Native Autocomplete Search in HTML
If you would like to see more Webtips, follow @flowforfrank

10 Best Practices for HTML
Looking to improve your skills? Check out our interactive course to master HTML from start to finish.
Master HTML

Resources:

Did you find this page helpful?
πŸ“š More Webtips
Frontend Course Dashboard
Master the Art of Frontend
  • check Unlimited access to hundreds of tutorials
  • check Access to exclusive interactive lessons
  • check Remove ads to learn without distractions
Become a Pro

Recommended

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_~