Skip to content
Tutorials Center
My learning

Topics

HTML Reference Β· Forms

The <option> element

Reference for the HTML <option> element: choices in a select and suggestions in a datalist, the value, label, selected and disabled attributes, and technical details.

The <option> element is one choice inside a <select> or <optgroup>, or one suggestion inside a <datalist>. Its text is what the user sees; its value is what gets submitted. If there is no value, the text is submitted instead.

HTML
<label for="lang">Language</label>
<select id="lang" name="lang">
  <option value="en">English</option>
  <option value="pt" selected>PortuguΓͺs</option>
</select>

Try it

Value, label, selected and disabled

Attributes

Attribute Values Description
value Text The value submitted when this option is selected. Defaults to the option's text, with surrounding whitespace removed and inner whitespace collapsed.
label Text A label for the option. When present, browsers display it instead of the text content.
selected Boolean The option is selected when the page loads (and after a form reset). In a single select, only one option should have it.
disabled Boolean The option can't be chosen. Options inside a disabled <optgroup> are disabled too.

It also accepts the global attributes.

Usage notes

  • Text for people, value for the server. Keep values stable codes (pt, pro) so you can reword the visible text later without breaking the backend.
  • Default selection. Without any selected, a drop-down starts on its first non-disabled option. A select with multiple starts with nothing selected.
  • selected is only the default. Changing it in a script with setAttribute affects the reset state; set option.selected = true or select.value to change the current choice.
  • Placeholder options. A first option with value="" ("Choose…") plus required on the select forces a real choice.
  • Plain text inside. In a classic select, an option holds text only; markup inside is ignored. The newer customizable select lets options contain richer content, but only where supported.
  • In a datalist, the value is what gets inserted into the input; the text or label may be shown as a hint.

Technical summary

Content categories None
Permitted content If it has a label attribute and a value attribute: nothing. If it has a label but no value: text. Otherwise: text (customizable select allows phrasing content)
Tag omission The end tag can be omitted if the option is immediately followed by another <option>, an <optgroup> or an <hr>, or if there is no more content in the parent element
Permitted parents <select>, <datalist> or <optgroup>
Implicit ARIA role option
DOM interface HTMLOptionElement
Default display block

Browser support

Supported in every browser.