Preview

How to Display Suggestions for Input Field in HTML ?

In most cases, there is a field on forms that allows for auto-completion of user input. This can be achieved using the HTML <datalist>. The <datalist> tag works with the input tag to enable users to quickly fill in data on forms by presenting them with a dropdown list of pre-defined options. In this article, we will explain how to create an input suggestion form using HTML and CSS, and demonstrate how to use the <datalist> tag to enable the auto-completion feature on your website.

Note: The element’s id attribute used in the <datalist> tag should be equal to the element’s list attribute in the <input> tag which will help to bind them together.

Similar Reads

Syntax:

... ...

Preview:

...

Approach:

Create a div with the class as a container. Inside this div, create another div with a class as a ‘text container’ that will contain the tag & tag. Declare the list attribute as a text container inside the tag. Similarly, declare the id attribute as the same as the list attribute, inside the tag. Now, create the drop-down list of programming languages for building the pre-defined options....