HTML list Attribute

❮ HTML Attributes

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>

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"/>



Browser Support




Status




Applies to:

The list attribute can be used on the following element:

Element Attribute
<input> list






Attribute Values

Value Description
datalistId Specifies the id of the datalist to provides a list of predefined values to the <input> element.
❮ HTML Attributes