<datalist>: The HTML Data List element
The <datalist>
HTML element contains a set of <option>
elements that represent the permissible or recommended options available to choose from within other controls.
Content categories | Flow content, phrasing content. |
---|---|
Permitted content |
Either
phrasing content
or zero or more <option> elements.
|
Tag omission | None, both the starting and ending tag are mandatory. |
Permitted parents | Any element that accepts phrasing content. |
Implicit ARIA role | listbox |
Permitted ARIA roles | No role permitted |
DOM interface | HTMLDataListElement |
Attributes
This element has no other attributes than the global attributes, common to all elements.
Examples
Basic datalist
<label for="myBrowser">Choose a browser from this list:</label>
<input list="browsers" id="myBrowser" name="myBrowser" />
<datalist id="browsers">
<option value="Chrome">
<option value="Firefox">
<option value="Internet Explorer">
<option value="Opera">
<option value="Safari">
<option value="Microsoft Edge">
</datalist>
Result
Specifications
Specification |
---|
HTML Standard # the-datalist-element |
Browser compatibility
BCD tables only load in the browser