{{HTMLSidebar}}
The <option>
HTML element is used to define an item contained in a {{HTMLElement("select")}}
, an {{HTMLElement("optgroup")}}
, or a {{HTMLElement("datalist")}}
element. As such, <option>
can represent menu items in popups and other lists of items in an HTML document.
{{EmbedInteractiveExample("pages/tabbed/option.html", "tabbed-standard")}}
Attributes
This element includes the global attributes.
disabled
- : If this Boolean attribute is set, this option is not checkable. Often browsers grey out such control and it won’t receive any browsing event, like mouse clicks or focus-related ones. If this attribute is not set, the element can still be disabled if one of its ancestors is a disabled
{{HTMLElement("optgroup")}}
element.
- : If this Boolean attribute is set, this option is not checkable. Often browsers grey out such control and it won’t receive any browsing event, like mouse clicks or focus-related ones. If this attribute is not set, the element can still be disabled if one of its ancestors is a disabled
label
- : This attribute is text for the label indicating the meaning of the option. If the
label
attribute isn’t defined, its value is that of the element text content.
- : This attribute is text for the label indicating the meaning of the option. If the
selected
- : If present, this Boolean attribute indicates that the option is initially selected. If the
<option>
element is the descendant of a{{HTMLElement("select")}}
element whosemultiple
attribute is not set, only one single<option>
of this{{HTMLElement("select")}}
element may have theselected
attribute.
- : If present, this Boolean attribute indicates that the option is initially selected. If the
value
- : The content of this attribute represents the value to be submitted with the form, should this option be selected. If this attribute is omitted, the value is taken from the text content of the option element.
Styling with CSS
Styling the <option>
element inside a <select>
dropdown is highly limited and depends on the browser and operating system. Depending on the operating system, the font-size
of the owning <select>
is respected in Firefox and Chromium. Chromium may additionally allow color
, background-color
, font-family
, font-variant
, and text-align
to be set.
You can find more details about styling <option>
in our guide to advanced form styling.
Examples
See {{HTMLElement("select")}}
for examples.
Technical summary
Content categories | None. |
---|---|
Permitted content |
Text, possibly with escaped characters (like
é ).
|
Tag omission |
The start tag is mandatory. The end tag is optional if this element is
immediately followed by another <option> element or an
`{{HTMLElement("optgroup")}}` , or if the parent element has no
more content.
|
Permitted parents | A `{{HTMLElement("select")}}` , an `{{HTMLElement("optgroup")}}` or a `{{HTMLElement("datalist")}}` element. |
Implicit ARIA role | option |
Permitted ARIA roles | No role permitted |
DOM interface | `{{domxref("HTMLOptionElement")}}` |
Specifications
{{Specifications}}
Browser compatibility
{{Compat}}
See also
- Other form-related elements:
{{HTMLElement("form")}}
,{{HTMLElement("legend")}}
,{{HTMLElement("label")}}
,{{HTMLElement("button")}}
,{{HTMLElement("select")}}
,{{HTMLElement("datalist")}}
,{{HTMLElement("optgroup")}}
,{{HTMLElement("fieldset")}}
,{{HTMLElement("textarea")}}
,{{HTMLElement("input")}}
,{{HTMLElement("output")}}
,{{HTMLElement("progress")}}
and{{HTMLElement("meter")}}
.