HTML datalist tag

HTML <datalist> element suggests different predefined options in an input field. We have to select one of the options. It must be used with <input> tag.

<p>Which is your favorite subject.</p>
 <input list="data" name="subject" />
 <datalist id="data">
  <option> Physics 
  <option> Chemistry 
  <option> Mathematics 
  <option> None 
 </datalist>

</>

Which is your favorite subject.

Tag Uses

Specific uses of <datalist> tag

datalist element offers the user different options to select only one option in a from. For instance, You are asked to choose one subject from different options.

Some browsers don't support datalist element. In this case, select element can be used inside datalist element.

Tag omission

Both starting and ending tags are necessary for the datalist element.

Global Attributes

All the global attributes are applicable on the datalist element.



Was this article helpful?