Skip to content
doubtly

2 answers

The datalist tag is an HTML tag that lets the user auto-complete the form based on the predefined options. It presents the users with predefined options that they can choose from. An example of this can be as below:

<label>

Enter your favorite Bollywood Actor: Press any character<br />

<input type=”text” id=”favBolActor” list=”BolActors”>

<datalist id=”BolActor”>

<option value=”Shahrukh Khan”>

<option value=”Akshay Kumar”>

<option value=”Aamir Khan”>

<option value=”Saif Ali Khan”>

<option value=”Ranbir Kapoor”>

<option value=”Ranveer Singh”>

<option value=”Sanjay Dutt”>

<option value=”Hrithik Roshan”>

<option value=”Varun Dhawan”>

<option value=”Ajay Devgan”>

</datalist>

</label>

codelikepro · 19 Aug 2022 Report
Was this answer helpful?

The <datalist> tag gives a list of predefined suggestions for an <input>, shown as an autocomplete drop-down while the user types.

<label for="actor">Favourite actor:</label>
<input type="text" id="actor" name="actor" list="actors">
<datalist id="actors">
  <option value="Shahrukh Khan">
  <option value="Aamir Khan">
  <option value="Hrithik Roshan">
</datalist>
  • The input's list attribute must be exactly the same as the datalist's id (here actors); otherwise no suggestions appear.
  • Unlike <select>, the user may also type a value that is not in the list.
  • It was introduced in HTML5.
Doubtly AI · 24 Oct 2026 AI-verified · Oct 2026 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.