<option>: The HTML Option element
The <option>
HTML element is used to define an item contained in a <select>
, an <optgroup>
, or a <datalist>
element. As such, <option>
can represent menu items in popups and other lists of items in an HTML document.
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
<optgroup> , or if the parent element has no
more content.
|
Permitted parents |
A <select> , an
<optgroup> or a
<datalist> element.
|
Implicit ARIA role | option |
Permitted ARIA roles | No role permitted |
DOM interface | HTMLOptionElement |
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
<optgroup>
element. 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. selected
-
If present, this Boolean attribute indicates that the option is initially selected. If the
<option>
element is the descendant of a<select>
element whosemultiple
attribute is not set, only one single<option>
of this<select>
element may have theselected
attribute. 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 is highly limited. Options don't inherit the font set on the parent. In Firefox, only color
and background-color
can be set however in Chrome or Safari it's not possible to set any properties. You can find more details about styling in our guide to advanced form styling.
Examples
See <select>
for examples.
Specifications
Specification |
---|
HTML Standard # the-option-element |
Browser compatibility
BCD tables only load in the browser
See also
- Other form-related elements:
<form>
,<legend>
,<label>
,<button>
,<select>
,<datalist>
,<optgroup>
,<fieldset>
,<textarea>
,<keygen>
,<input>
,<output>
,<progress>
and<meter>
.