HTML <datalist> Tag

Beginner
5 min read
Updated: Oct 2026
4 examples
Live preview

Definition and Usage

The <datalist> element holds a set of <option> suggestions for another control — usually an <input>.

Give the list an id, then set the input’s list attribute to that same id. Users can pick a suggestion or type a different valid value. It is not a drop-in replacement for <select>.

Limited availability (not full Baseline).

Widely useful in modern browsers, but support and UI details vary by input type. Always test critical forms.

Accessibility caution.

Suggestion popups may not zoom with page zoom, are hard to restyle for high contrast, and some screen reader/browser pairs do not announce options well (MDN).

HTML Syntax

syntax.html
<input list=" id">
<datalist id="id"><option value="…"></datalist>

Both start and end tags are required. Put zero or more <option> children (or phrasing content). The control that receives suggestions is separate from the list itself.

Attributes

<datalist> has no tag-specific attributes beyond globals. The wiring that matters:

AttributeDescriptionTry it
id (on <datalist>)Unique id that the input’s list points toTry it
list (on <input>)Must match the datalist id to show those suggestionsTry it
value (on <option>)Suggested string entered into the control when chosenTry it
label (on <option>)Optional human label; browser display of label vs value variesTry it

Global Attributes

The <datalist> tag also supports the Global Attributes in HTML.

Live Preview

Focus or click the field and pick a suggestion. You can also type a custom value.

A real <input list="…"> bound to <datalist>.

Input + datalist

list="datalist-live-options" — ice cream flavors

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Text Suggestions

Wire an input to a datalist with matching list and id.

HTML
<label for="flavor">Choose a flavor:</label>
<input list="flavors" id="flavor" name="flavor">

<datalist id="flavors">
  <option value="Chocolate">
  <option value="Mint">
  <option value="Strawberry">
  <option value="Vanilla">
</datalist>
Try It Yourself

How It Works

  1. Label the input with for / id for accessibility.
  2. Set list on the input to the datalist’s id.
  3. Add <option value="…"> suggestions inside <datalist>.
  4. Use the field. Pick a suggestion or type another valid value.

Example 2 — Email Field Suggestions

Common addresses or domains as optional shortcuts for type="email".

HTML
<label for="work-email">Work email:</label>
<input type="email" list="emails" id="work-email" name="work-email">

<datalist id="emails">
  <option value="[email protected]">
  <option value="[email protected]">
  <option value="[email protected]">
</datalist>
Try It Yourself

How It Works

  1. Use a fitting input type (email, url, tel, etc.).
  2. Keep suggestions realistic so they help, not confuse.
  3. Remember validation. type="email" still checks format for typed values.
  4. Suggestions are optional — the user is not locked to the list.

Example 3 — Range Tick Marks

For type="range", option values can appear as selectable ticks (UI varies).

HTML
<label for="tip">Tip amount:</label>
<input type="range" list="ticks" min="0" max="50" id="tip" name="tip" value="20">

<datalist id="ticks">
  <option value="0" label="0%">
  <option value="10" label="Min">
  <option value="20" label="Standard">
  <option value="30" label="Generous">
  <option value="50" label="Max">
</datalist>
Try It Yourself

How It Works

  1. Use type="range" with min / max.
  2. Point list at a datalist of tick values.
  3. Optional label may show beside ticks in some browsers.
  4. Test the UI — tick appearance is browser-specific.

Example 4 — datalist vs <select>

Use datalist for optional hints; use select when the choice must be from a fixed set.

HTML
<!-- Suggestions only (free text allowed) -->
<label for="city">City:</label>
<input list="cities" id="city" name="city">
<datalist id="cities">
  <option value="Chennai">
  <option value="Mumbai">
  <option value="Delhi">
</datalist>

<!-- Fixed choice required -->
<label for="region">Region:</label>
<select id="region" name="region">
  <option value="south">South</option>
  <option value="west">West</option>
  <option value="north">North</option>
</select>
Try It Yourself

How It Works

  1. datalist: recommends values; other input is still allowed.
  2. select: the control is the list of allowed choices.
  3. Pick by product need. Open answers → datalist; closed set → select.
  4. Do not fake a select with datalist if only listed values are valid — validate on the server too.

Edge Cases & Pitfalls

Most bugs are mismatched ids, treating datalist like select, or assuming identical UI everywhere.

wiring

id and list must match

If list does not equal the datalist id, suggestions never appear.

semantics

Not a select replacement

Users can enter values outside the list. Use <select> (plus server checks) for a closed set.

a11y

Assistive tech gaps

Some combinations do not announce the popup; option text may not zoom. Label inputs clearly and test.

css

Limited styling

You cannot reliably theme the native suggestion menu. Expect the browser’s default UI.

types

Support varies by input type

Text-like types are the common case. Range ticks, color swatches, and date UIs differ across browsers.

Browser Support

The <datalist> element is standard HTML, but MDN marks it limited availability because behavior is not identical everywhere.

✓ Limited availability

<datalist>

Supported in modern Chrome, Firefox, Safari, Edge, and Opera for common text-like inputs. Exact menus, range ticks, and color presets vary. Internet Explorer had partial support only.

92% Global support (approx.)
Google Chrome 20+
Supported
Mozilla Firefox 4+
Supported
Apple Safari 12.1+
Supported
Microsoft Edge 12+
Supported
Opera 9.5+
Supported
Samsung Internet All
Supported
Internet Explorer 10*
Partial
<datalist> Broad modern support

Bottom line: Fine for progressive enhancement. Do not rely on datalist alone for required closed choices or critical accessibility without testing.

Key Takeaways

  • Role: optional suggestions for an input, not a locked choice list.
  • Wire: list on input = id on <datalist>.
  • Options: each suggestion needs a value the input can accept.
  • Choose carefully: closed sets belong in <select>; test a11y and input types.

One line: <datalist> suggests values for an <input list="…"> — it does not force them.

Default CSS Settings

The datalist itself is not shown as page content; the browser draws the suggestion UI. Typical author CSS cannot restyle that popup.

default.css
datalist {
  display: none; /* suggestions appear via the bound control's UI */
}

Style the associated <input> (and its label) as usual; leave the native list UI to the browser.

Frequently Asked Questions

The datalist element holds option suggestions for another control, usually an input. Link them with matching id on datalist and list on the input.
No. select forces a choice from a fixed list. datalist only suggests values; the user can still type something else that passes validation.
Commonly text, search, url, tel, email, and number show a suggestion menu. date/time types, range (tick marks), and color can also use predefined options, with varying UI by browser.
No tag-specific attributes beyond the global attributes. The important hook is id, which must match the input list attribute.
Browser UI for the popup is largely unstyled. You cannot reliably theme it like a custom select; plan for native look and limited CSS control.
Support and announcements vary. Some screen reader and browser pairs do not announce suggestions well, and option text may not zoom with page zoom. Prefer clear labels and test with assistive tech.

Next: dd

Describe a term in a description list with the dd element.

dd tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful