HTML <select> Tag

Beginner
6 min read
Updated: Nov 2026
4 examples
Live preview

Definition and Usage

The <select> element creates a menu of options — usually a dropdown, or a scrolling list box when multiple or size greater than 1 is set.

Nest <option> (and optional <optgroup>) children. Give the control a name for form data, and pair it with a <label> for accessibility. Prefer <datalist> when users may still type free text.

Baseline · Widely available.

Not deprecated. Core select support has been stable across browsers since about July 2015 (and much earlier in practice).

Experimental extras.

Fully customizable selects (e.g. <button> / <selectedcontent> patterns) are newer and have limited support — learn classic <select> + <option> first.

HTML Syntax

syntax.html
<select name=" field">…options…</select>

Both start and end tags are required. Put options (and optional groups or <hr> separators) inside the select.

Attributes

Element-specific attributes on <select> (plus globals):

AttributeDescriptionTry it
nameKey used when the selected value(s) are submitted with the formTry it
multipleAllows zero or more options to be selected at onceTry it
sizeVisible rows; default 1, or 4 when multiple is setTry it
requiredUser must pick a non-placeholder option before submitTry it
disabledControl cannot be used or submittedBoolean attr
autofocusFocus this control when the page loads (one per document)Boolean attr
formAssociates the select with a <form> by that form’s idForm owner
autocompleteHint for the browser’s autofill featureOptional

Global Attributes

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

Live Preview

Switch common select patterns and see the control update live.

Real <select> markup. Apply a pattern to compare dropdown, groups, and multiple.

Preview

Basic dropdown — one choice from a short list.

HTML Examples

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

Example 1 — Basic Dropdown

A labeled select with a placeholder option and clear values.

HTML
<label for="pet-select">Choose a pet:</label>
<select name="pets" id="pet-select" required>
  <option value="">--Please choose an option--</option>
  <option value="dog">Dog</option>
  <option value="cat">Cat</option>
  <option value="hamster">Hamster</option>
</select>
Try It Yourself

How It Works

  1. Link a <label> with matching for / id.
  2. Set name so the chosen value is submitted with the form.
  3. Add a placeholder option with value="" as the first direct child.
  4. Use required so submit fails until a real option is picked.

Example 2 — Default Selected Option

Preselect a common choice with selected on an option.

HTML
<label for="size">T-shirt size:</label>
<select id="size" name="size">
  <option value="s">Small</option>
  <option value="m" selected>Medium</option>
  <option value="l">Large</option>
</select>
Try It Yourself

How It Works

  1. Users see the label text (Small, Medium, Large).
  2. value is what gets submitted (s, m, l).
  3. selected marks the default when the page loads.
  4. Without selected, browsers typically select the first option.

Example 3 — Grouped Options

Use <optgroup> to split long lists into labeled categories.

HTML
<label for="food">Favorite food:</label>
<select id="food" name="food">
  <option value="">Choose a food</option>
  <optgroup label="Fruit">
    <option value="apple">Apples</option>
    <option value="banana">Bananas</option>
  </optgroup>
  <optgroup label="Vegetables">
    <option value="broccoli">Broccoli</option>
    <option value="cabbage">Cabbages</option>
  </optgroup>
</select>
Try It Yourself

How It Works

  1. Wrap related options in <optgroup label="…">.
  2. Group labels are not selectable — only options submit values.
  3. Keep groups short so the menu stays scannable.
  4. Optional <hr> can add visual separators between groups in supporting browsers.

Example 4 — Multiple Selection List

Allow more than one choice with multiple and show several rows with size.

HTML
<label for="pets">
  Choose one or more pets (Ctrl/Cmd+click):
</label>
<select id="pets" name="pets" multiple size="4">
  <optgroup label="4-legged">
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
    <option value="hamster" disabled>Hamster</option>
  </optgroup>
  <optgroup label="Flying">
    <option value="parrot">Parrot</option>
    <option value="macaw">Macaw</option>
  </optgroup>
</select>
Try It Yourself

How It Works

  1. multiple turns the control into a multi-select list box.
  2. size="4" shows four visible rows (users can scroll for more).
  3. Tell users how to multi-select in the label text.
  4. disabled on an option blocks that choice (here, Hamster).

Edge Cases & Pitfalls

Most mistakes skip labels, misuse placeholders, or surprise users with multi-select.

a11y

Always provide a visible label

Placeholder text inside the first option is not a substitute for <label>. Screen readers need a real association.

required

Placeholder must use empty value

For a single-select dropdown, the placeholder is the first direct <option value=""> child. Other empty-value options count as real choices.

multiple

Explain multi-select UX

Keyboard and pointer gestures vary by OS. Tell users they can pick more than one option, especially when the control looks like a dropdown.

vs datalist

Closed list vs suggestions

Use <select> when only listed values are valid. Use <datalist> when free text is still allowed.

styling

Native look is hard to restyle

Browsers limit how far you can restyle the closed and open states. Prefer native controls for reliability unless you need a fully custom widget.

Browser Support

The <select> element is a core HTML form control in every major browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

<select>

Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera all support select, option, optgroup, multiple, and size. Some advanced customization features vary by browser.

98% Global support (approx.)
Google Chrome All
Full support
Mozilla Firefox All
Full support
Apple Safari All
Full support
Microsoft Edge All
Full support
Opera All
Full support
Samsung Internet All
Full support
Internet Explorer All
Supported
<select> Widely supported

Bottom line: Safe to use everywhere for option menus. Label every select, and test multiple-select UX on keyboard and touch.

Key Takeaways

  • Role: <select> presents a fixed menu of options for forms.
  • Children: use <option>, optional <optgroup>, and a matching <label>.
  • multiple / size: multi-select and visible row count change the control into a list box.
  • vs datalist: closed choices → select; suggestions + free text → datalist.

One line: label the control, nest options (and groups), and set name for the submitted value.

Default CSS Settings

Browsers render select as an inline-block form control with platform chrome. A simplified idea:

default.css
select {
  display: inline-block;
  font: inherit;
}

Exact arrows, borders, and open-menu styling are browser- and OS-specific.

Frequently Asked Questions

The select element creates a menu of options — usually a dropdown, or a scrolling list box when multiple or size greater than 1 is set. Users pick one or more choices to submit with a form.
Yes for accessibility. Associate a label with for matching the select’s id (or wrap the select inside the label) so assistive technology can announce the control’s purpose.
select limits the user to the listed options. datalist suggests values for an input but still allows free text.
Add the multiple attribute. Tell users how to multi-select (for example Ctrl/Command+click on desktop). Multiple values are submitted as repeated name=value pairs.
size sets how many option rows are visible. Default is 1 (dropdown) unless multiple is set, which defaults size to 4 and usually shows a list box.
Without multiple and without size greater than 1, the implicit role is combobox. Otherwise it is listbox.

Next: shadow

Explore the obsolete HTML shadow element and modern alternatives.

shadow 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.

11 people found this page helpful