The quick answer: use a
<select>
when the user must pick from a fixed, known list of options, and use an HTML
<datalist>
when you want to offer suggestions but still let people type their own value. The core of the html datalist vs select decision comes down to one question: are you forcing a choice, or nudging one? A select locks users into your options; a datalist input gives autocomplete suggestions while keeping free text on the table.
Content Table
How each element actually works
Both elements render a dropdown, but they behave very differently under the hood.
A
<select>
is a closed menu. The value submitted is always one of your
<option>
elements, and the user cannot type anything you didn't define.
<label for="country">Country</label>
<select id="country" name="country">
<option value="">Choose one</option>
<option value="us">United States</option>
<option value="ca">Canada</option>
<option value="mx">Mexico</option>
</select>
The HTML
<datalist>
tag is different. It attaches a list of suggestions to a regular
<input>
using the
list
attribute. The input stays a normal text field, so users can pick a suggestion or type something entirely new.
<label for="browser">Favorite browser</label>
<input id="browser" name="browser" list="browsers">
<datalist id="browsers">
<option value="Chrome">
<option value="Firefox">
<option value="Safari">
<option value="Edge">
</datalist>
Notice the datalist options have no closing tags or inner text, just a
value. The input above will still accept "Brave" or "Opera" even though they aren't listed.
The key differences at a glance
| Behavior | ||
|---|---|---|
| Free text allowed | No | Yes |
| Autocomplete as you type | Partial (jumps to matches) | Yes, filters suggestions |
| Value guaranteed from list | Yes | No (needs validation) |
| Supports option groups | Yes (optgroup) | No |
| Multi-select | Yes (multiple) | No |
| Styling flexibility | Limited | It's a text input, easier |
When to use select
Reach for
<select>
when the answer set is fixed and you can't accept anything outside it. Good fits:
- Country, state, or currency pickers where every valid value is known.
- Yes/No or status choices like "Subscription plan" or "Priority: Low / Medium / High".
-
Lists that need option groups. A
<select>can wrap options in<optgroup label="...">to group related items, something a datalist cannot do. -
Multiple selection
, which only
<select multiple>supports natively.
The big win is that a select guarantees a clean value. You never have to worry about typos or unexpected input reaching your backend. That's the same reasoning behind choosing radio buttons for short, fixed choices when the list is small enough to show all at once.
When to use datalist
A datalist input shines when a value is usually from a known set but could reasonably be something new. It gives autocomplete suggestions without trapping the user.
- Job titles, cities, or tags where you want to suggest common answers but allow anything.
- Search-style fields where speeding up typing matters more than restricting it.
- Long lists a user can filter by typing, instead of scrolling through hundreds of options.
- Progressive fields where suggestions grow from past entries or popular values.
<select>
all along.
Accessibility and browser support
HTML select element accessibility is one of its quiet strengths. Screen readers announce it reliably, keyboard users can open it and navigate with arrow keys, and its behavior is consistent everywhere. It has been rock-solid for decades.
The datalist story is bumpier. Per
MDN's datalist documentation, support is broad in modern browsers, but the way suggestions get announced to assistive tech is inconsistent, and some mobile browsers render it awkwardly. Always pair it with a visible
<label>
and consider adding helper text so users know free text is allowed.
A few practical accessibility tips for both:
-
Always connect a
<label for="...">to the control'sid. - Group related form controls with fieldset and legend so the structure makes sense to screen readers.
- For datalist, don't rely on the suggestions being read aloud; describe the field's purpose in the label or nearby text.
Forcing a valid choice with datalist
Because a datalist input accepts free text, you sometimes need to validate that the value matches your list. The cleanest way to nudge users toward valid input is the pattern attribute for input validation, though for a dynamic list you'll usually check on the server too.
Here's a simple client-side pattern example that only allows two specific values:
<input list="sizes" name="size" pattern="Small|Medium|Large" required>
<datalist id="sizes">
<option value="Small">
<option value="Medium">
<option value="Large">
</datalist>
If you truly need a guaranteed value with no typos, skip the workaround and use a
<select>
. Validation on top of a datalist is fine for filtering, but it's easy to get wrong, and server-side checks are still a must. Whenever a form actually submits data, make sure you also understand what the
form action attribute does
so the input ends up where you expect it.
Ship your form with select or datalist, no backend needed
Once you've picked between an HTML datalist vs select for your form, SendForm delivers the submissions to your inbox, Slack, or a webhook without any server to run.
Create a serverless contact form →
Not on its own. A datalist input always allows free text. You can add a
pattern
attribute or JavaScript to reject non-matching values, but if you need a guaranteed choice with zero typos, a
<select>
is the safer element for that job.
No. Only
<select>
supports grouping through the
<optgroup>
element with a label. A datalist presents a flat list of suggestions with no headings, so if you need visually grouped options, choose a select instead.
The
<select>
element has more consistent and mature support across screen readers and keyboards. Datalist support varies, and its suggestions aren't always announced clearly. Both need a proper
<label>
, but select is the more reliable choice for accessibility-critical forms.
Barely. The suggestion popup is rendered by the browser and isn't customizable with CSS. The input field itself is a normal text input, so you can style that freely. If you need a fully styled dropdown, a custom JavaScript component is usually required.
Mostly, yes, but the experience varies. Some mobile browsers show suggestions in an unusual way or hide them behind the keyboard. Test on real devices before relying on it, and always allow the plain typed value to be valid so mobile users are never stuck.