Type in the field or open its native suggestions. Values outside the list are still allowed.
Configured suggestions
-
HTMLMarkup language -
CSSStyle sheets -
JavaScriptProgramming language -
TypeScriptTyped JavaScript
Explore datalist as a collection of suggested values for an input. Change the control type, configure attributes, and compare native menus, range ticks, and pickers without restricting the value to the available options.
Type in the field or open its native suggestions. Values outside the list are still allowed.
HTMLMarkup language
CSSStyle sheets
JavaScriptProgramming language
TypeScriptTyped JavaScript
<label for="preferred-technology">Preferred technology</label>
<input
type="text"
id="preferred-technology"
name="suggested-value"
list="technology-suggestions"
placeholder="Type or choose a technology"
autocomplete="off"
/>
<datalist id="technology-suggestions">
<option value="HTML" label="Markup language"></option>
<option value="CSS" label="Style sheets"></option>
<option value="JavaScript" label="Programming language"></option>
<option value="TypeScript" label="Typed JavaScript"></option>
</datalist>Educational guide to datalist
Connect an input to a suggestion list while preserving free-form entry. Learn which value is inserted, what validates the field, and when another control is a better fit.
There is an editable field, a source of suggestions, and a final value. Each part has a different responsibility.
Receives focus, has a label, and holds the value that would be submitted under its name.
Groups options and connects to the field through list and id. It is not another form field.
Can come from an option or free-form typing, subject to the input constraints.
datalist helps complete a value. It does not make the field a closed choice or validate list membership on its own. First decide whether your product accepts new values; that decision determines whether suggestions are the right pattern.
The label identifies the field; list identifies its suggestion source.
The label for matches the input id. The input list instead matches the datalist id, without #. Use unique IDs within the same document tree: repeating a recipe with the same IDs can connect the field to another list.
Reference suggestions for this example:
Activation, filtering, and the number of visible results depend on the browser and device. Do not assume fuzzy search or an identical keyboard shortcut. The visible list in this recipe is reference text, not a second interactive menu.
What helps identify an option can differ from what is inserted into the field.
With value="MAD" label="Madrid", choosing the suggestion inserts MAD. Label presentation varies. Also distinguish option label, which describes a suggestion, from the input label, which names the whole field.
Reference suggestions for this example:
For a form, the relevant data is the current input value under its name; datalist does not submit another selection. If you need to show a description and store a hidden identifier with a mandatory mapping, design that relationship explicitly: datalist does not enforce it.
required demands content; the type and other attributes define the field constraints.
An empty email required field is invalid, as is text that fails the email format. A valid address outside the suggestions can still pass native validation. Likewise, min, max, and step constrain compatible types: options do not replace these attributes.
Browser validation helps people use the form; the server validates received data. If you only accept catalogue members, check this on the server and choose an interaction that communicates the restriction. Do not try to enforce it through required alone.
Choose by the data contract and user needs, rather than list length alone.
Use input + datalist to suggest without blocking new values. A select provides a choice among defined options: its visible text and submitted value can also differ. For a few options that should be visible together, consider native radios.
autocomplete guides the browser about saved data such as name or email; list supplies suggestions from the document. They can coexist. autocomplete="off" does not make datalist a closed control or guarantee identical presentation. Preserve useful personal-data autofill; do not disable it routinely.
A custom combobox needs its own keyboard, focus, selection, and accessible announcement handling. Adding role="combobox" or a CSS-drawn popup does not provide this. Consider that complexity only when native controls cannot meet a specific need and you can verify it with assistive technology.
Separate association failures, the data contract, and limitations of the native interface.
API presence does not guarantee every type’s popup or a uniformly accessible experience.
On the review date, Web Platform DX and MDN classify datalist as Limited Availability: Firefox for Android retains a suggestion-menu limitation. Check each type too: text and email, dates/times, colours, and range ticks can show different interfaces or offer no suggestions.
For range, options may provide tick marks; min, max, and step still constrain the value. Do not rely on their labels being visible in every browser. For temporal and colour types, verify the real picker and expected value format before reusing a playground example.
MDN documents popup limitations: option text that does not scale with zoom, little high-contrast customisation, and reader/browser combinations that do not announce suggestions. Input CSS alone does not solve these issues. Test zoom, keyboard, mobile, and the assistive technology your audience uses.
If suggestions are unavailable, the input still allows manual entry according to its type. That is only a sufficient alternative when suggestions are optional and the value can be discovered another way. These scenes keep visible references where they help interpret values; they do not simulate support or install a polyfill.