Advertisement
Home Open Editor ❯

HTML list Attribute

Example

<label for="text">Choose your fav fruit:</label>
<input list="fruits" name="fruit" id="text"/><br><br>

<datalist id="fruits">
  <option>apple</option>
  <option>banana</option>
  <option>mango</option>
  <option>orange</option>
  <option>blueberry</option>
</datalist>

Try this code ❯

Meaning

The list attribute is used to set the id of a datalist element used to provide a predefined list of options suggested to the user for entry.

The <datalist> provides a list of predefined values to suggest to the user for this input.


Standard Syntax

HTML:<input list="datalistId">,
XHTML:<input list="datalistId"/>


Applies to:

The list attribute can be used on the following element:

Element Attribute
<input> list

Advertisement

Attribute Values

Value Description
datalistId Specifies the id of the datalist to provides a list of predefined values to the <input> element.
Home Open Editor ❯
Advertisement