HTML select element

Reference for the HTML select element: option and optgroup, form values when multiple is set, and disabled or required controls.

标签页正文目前为英文。

The select element is a form control for choosing among a list of options. This page deepens the catalog card for <select>. option and optgroup are covered here rather than as separate thin pages. It does not replace the tag catalog or rewrite the form and input pages.

Permitted content is zero or more option, optgroup, and script-supporting elements. The current HTML Standard also allows hr as a separator inside select or optgroup; that separator is newer, support varies, and it is not demonstrated here. Both start and end tags are required. The implicit ARIA role is typically combobox for a single-selection closed list, or listbox when multiple is set or size is greater than 1. This page does not claim a role mapping was tested in a browser.

Examples are complete HTML fragments with a local form and no third-party action. They were checked with Python 3.13's html.parser as a structural tree, and with the site build. The forms are not submitted here, and this is not a browser, accessibility, or constraint-validation test.

Official sources: MDN <select> element and the WHATWG HTML Living Standard. Fragments were checked with Python 3.13 html.parser. That parser builds an element tree; it is not a WHATWG conformance checker, and this is not a browser or accessibility test.

HTML tag catalog → · HTML tutorial overview →

Purpose and content model

Use select when the user should pick from a known set of values. A single-selection select without size is usually presented as a drop-down. multiple turns it into a multi-select list. size can show more than one row even for a single-selection control.

A name is required for the control to be submitted. The submitted value comes from the selected option element (or elements), not from text on the select itself. Associate a label with for and id, as on the label and form pages.

option, optgroup, and values

Each option represents one choice. If the value attribute is omitted, the option's value is its text content. A selected attribute marks the default choice. A disabled option cannot be chosen and is not a successful value.

optgroup groups options under a label attribute on the group. A disabled optgroup disables the options in that group. The first example uses a required single-selection select, a placeholder option with an empty value, and one disabled option. Constraint validation was not run here.

A required select with optgroup and a disabled option

<select name required>
  <option value="" selected disabled>
  <optgroup label>
    <option value>
  </optgroup>
</select>

A placeholder option with an empty value keeps a required single-selection select incomplete until a real option is chosen.

AttributeDescription
nameThe field name used in form submission. Without name, the control is not submitted.
requiredA boolean. For a single-selection select, the control is incomplete while the selected option has an empty value. This page does not run constraint validation.
value (option)The option's submitted value. If omitted, the value is the option's text content.
selected (option)Marks the default selected option. In a single-selection select, at most one option should be selected in the markup.
disabled (option)The option cannot be chosen and is not a successful control. A disabled placeholder can still be the initial selected option.
label (optgroup)The visible group heading. A disabled optgroup disables the options it contains.
  • There is no remote form action. The fragment is not submitted, and no user-agent picker UI was opened.
html
<form>
  <label for="region">Region</label>
  <select id="region" name="region" required>
    <option value="" selected disabled>Choose a region</option>
    <optgroup label="Americas">
      <option value="us">United States</option>
      <option value="ca">Canada</option>
    </optgroup>
    <optgroup label="Europe">
      <option value="de">Germany</option>
      <option value="fr" disabled>France (unavailable)</option>
    </optgroup>
  </select>
  <button type="submit">Save region</button>
</form>

What this markup means

The placeholder option has an empty value, is selected, and is disabled so it is only a prompt. Choosing United States would submit region=us if this form were submitted. The France option is disabled in the tree, so it is not a successful value. Nothing is submitted from this page.

Related: Tag catalog: <select>, <form>, <label>, <input>

MDN documentation → · WHATWG HTML Standard →

multiple values, disabled, and required

When multiple is set, every selected option is a successful value for the same name. A form dataset would include one entry per selected option, such as lang=en and lang=zh, not a single joined string. This page records that rule from the HTML Standard; it does not submit the example and does not invent a wire-level result.

disabled on the select element disables the whole control. A disabled select is not a successful control, even if an option is marked selected. required on a multiple select means at least one option should be selected; again, validation is not executed here. size hints how many rows are visible and does not cap how many options can be selected.

multiple selected values and a disabled select

<select name multiple>
  <option value selected>
</select>
<select name disabled>

A multiple select can contribute several values with the same name. A disabled select is omitted from submission.

AttributeDescription
multipleA boolean. When present, more than one option may be selected, and each selected option is submitted under the same name.
sizeSuggested number of visible rows. It is not a limit on how many options may be selected.
disabled (select)Disables the entire control. The control is not successful and is not submitted.
requiredOn a multiple select, at least one option should be selected. This is a client constraint only, and it is not run here.
  • The second select is disabled on purpose so it can be contrasted with the multiple control. No form data is generated from this fragment.
html
<form>
  <label for="langs">Languages</label>
  <select id="langs" name="lang" multiple size="4">
    <option value="en" selected>English</option>
    <option value="zh" selected>Chinese</option>
    <option value="ja">Japanese</option>
    <option value="es" disabled>Spanish (unavailable)</option>
  </select>
  <label for="plan">Plan</label>
  <select id="plan" name="plan" disabled>
    <option value="basic" selected>Basic</option>
    <option value="pro">Pro</option>
  </select>
</form>

What this markup means

English and Chinese are selected on a multiple select named lang, so a submission would include both lang=en and lang=zh. Spanish is a disabled option, so it is not a successful value even if a user could see it. The plan select is disabled as a whole, so its selected Basic option would not be submitted. This tree was not submitted.

Related: Tag catalog: <select>, <form>, <label>

MDN documentation → · WHATWG HTML Standard →