datalist – suggested values
<input list="list-id"><datalist id="list-id"><option value="…"></datalist>
A list of suggestions for an input field: while the visitor types, the browser offers matching values, but the visitor may also type anything else. The field is connected with the list by the list attribute. Useful for long menus (cities, brands) where a select would be unwieldy.
- Default display:
display: none - End tag: required
- Content:
optionelements (or phrasing content with them) - Where it can be used: anywhere phrasing content is allowed
- DOM interface:
HTMLDataListElement
Attributes
Only global attributes – mainly the id that list on the field refers to.
Examples
A field with suggested cities:
<label for="d-city">City</label> <input id="d-city" name="city" list="d-cities" autocomplete="off"> <datalist id="d-cities"> <option value="Springfield"> <option value="Chicago"> <option value="Boston"> </datalist>
Things to watch out for
datalistdoes not restrict the value – when it must be one from the menu, useselect, or check it on the server.- The look of the suggestions is determined by the browser and cannot be styled.
Browser support
Not Baseline yet: it does not work in all major browsers, including mobile ones, yet. Since version: Chrome 20, Firefox 4, Safari 12.1. As of October 2026 (MDN browser-compat-data). Baseline is held back by missing support in Firefox for Android; Firefox on desktop does not show suggestions for date, time and color fields.
Related:
input – input field
option – list option
select – drop-down list