Skip to content

<datalist> - The Datalist Element

Form Control HTML5

The datalist element provides a list of predefined options for an <input> element, creating an autocomplete dropdown. Users can either select from the list or type their own value.

Result
<input type="text" list="datalist-id">
<datalist id="datalist-id">
<option value="Option 1">
<option value="Option 2">
<option value="Option 3">
</datalist>

Connect the input to the datalist using the input’s list attribute with the datalist’s id.

The <datalist> element has no specific attributes beyond the global attributes like id and class.

The id attribute is required to link it with an input element.

Result
Result
Result
Result
Result
Result
Result
Result
Result
Result
Result
<!-- Allow custom input + suggestions -->
<input type="text" list="countries">
<datalist id="countries">
<option value="United States">
<option value="United Kingdom">
<option value="Canada">
</datalist>

Use when: Users might need custom values, list is too long to scroll, or autocomplete/search behavior is desired.

Result
Result
Result

Datalist is fully keyboard accessible:

  • Type: Filters suggestions
  • Arrow Down: Open/navigate suggestions
  • Arrow Up/Down: Navigate through options
  • Enter: Select highlighted option
  • Escape: Close suggestions
<datalist id="cities">
<option value="New York">
<option value="Los Angeles">
<option value="Chicago">
</datalist>
<!-- 10-50 suggestions work well -->
<datalist id="popular">
<option value="Option 1">
<option value="Option 2">
<!-- ... 20 more options -->
</datalist>

For very large lists, consider server-side filtering or alternative UI patterns.

Result
BrowserVersionNotes
Chrome20+Full support
Firefox4+Full support
Safari12.1+Full support
Edge12+Full support
IE10+Partial support (limited styling)