list

Connects an input to a datalist of suggestions. The browser provides autocomplete-style filtering without any JavaScript.

Overview

The list attribute connects an <input> to a <datalist> element that provides a set of suggested values. The browser shows these suggestions as a dropdown that filters as the user types. Unlike a <select>, the user can still type a value that is not in the list.

This is the native HTML autocomplete/typeahead — no JavaScript required for the basic behavior.

Applies to: <input> (most types)

Values

ComponentPurpose
list="id" on inputPoints to the <datalist> by its id
<datalist id="id">Contains <option> elements with suggested values
<option value="...">Each suggestion. The value is what gets filled in.

Basic Text Suggestions

The simplest pattern: a text input with a list of suggestions. The browser filters options as the user types, matching against the value attribute.

The user can select from the list or type any value they want. The list is a suggestion, not a constraint.

Labels and Values

Options can have inner text that serves as a visible label. The value attribute is what gets submitted. Some browsers show both the label and value in the dropdown.

Email Suggestions

On type="email", the datalist provides email address suggestions. This is useful for fields where the user frequently enters the same addresses.

URL Suggestions

On type="url", the datalist can suggest common URLs. The browser still validates that the final value is a valid URL.

Number Suggestions

On type="number", the datalist suggests specific numeric values. The user can still type any number within the min/max range.

Range Tick Marks

On type="range", the datalist creates visible tick marks on the slider track. The label attribute on options may be displayed as tick labels (browser support varies).

This is one of the most underused native features. Tick marks turn a plain slider into a meaningful control with visible reference points — no JavaScript needed.

Dynamic Suggestions

Populate the datalist dynamically with JavaScript for server-driven autocomplete. The browser automatically picks up new options added to the datalist.

Accessibility

  • Screen readers announce datalist-connected inputs as having suggestions. Users can arrow through options.
  • The datalist does not replace a <label>. Always provide a visible label for the input.
  • Since the user can type values not in the list, datalist is better for suggestions than for constrained choices. Use <select> when the user must pick from a fixed set.
  • Keyboard navigation: Arrow Down opens the suggestion list, arrow keys navigate, Enter selects.

Limitations

  • Datalist rendering varies significantly across browsers. Chrome shows a dropdown below the input, Firefox shows inline suggestions, and Safari has historically had limited support.
  • You cannot style the datalist dropdown with CSS. The appearance is entirely controlled by the browser.
  • The list attribute does not work on type="hidden", type="password", type="checkbox", type="radio", type="file", or type="image".
  • There is no event fired when the user selects an option from the datalist. You must listen for input or change events on the input itself.
  • Filtering logic is browser-controlled. You cannot customize whether matching is case-sensitive, starts-with, or contains.
  • On mobile browsers, datalist support and UX can be inconsistent. Test on your target devices.

See Also

  • autocomplete — browser autofill for personal data
  • multiple — accept multiple values in one field
  • <select> — constrained choice from a fixed set
  • <input> element reference