<optgroup>: The Option Group element
The <optgroup>
HTML element creates a grouping of options within a <select>
element.
Content categories | None. |
---|---|
Permitted content | Zero or more <option> elements. |
Tag omission |
The start tag is mandatory. The end tag is optional if this element is
immediately followed by another <optgroup> element, or
if the parent element has no more content.
|
Permitted parents | A <select> element. |
Implicit ARIA role | group |
Permitted ARIA roles | No role permitted |
DOM interface | HTMLOptGroupElement |
Note: Optgroup elements may not be nested.
Attributes
This element includes the global attributes.
disabled
-
If this Boolean attribute is set, none of the items in this option group is selectable. Often browsers grey out such control and it won't receive any browsing events, like mouse clicks or focus-related ones.
label
-
The name of the group of options, which the browser can use when labeling the options in the user interface. This attribute is mandatory if this element is used.
Examples
<select>
<optgroup label="Group 1">
<option>Option 1.1</option>
</optgroup>
<optgroup label="Group 2">
<option>Option 2.1</option>
<option>Option 2.2</option>
</optgroup>
<optgroup label="Group 3" disabled>
<option>Option 3.1</option>
<option>Option 3.2</option>
<option>Option 3.3</option>
</optgroup>
</select>
Result
Specifications
Specification |
---|
HTML Standard # the-optgroup-element |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
optgroup | ChromeFull support1 | EdgeFull support12 | FirefoxFull support1 | Internet ExplorerFull support5.5 | OperaFull supportYes | SafariFull supportYes | WebView AndroidFull supportYes | Chrome AndroidFull supportYes | Firefox for AndroidFull support4 | Opera AndroidFull supportYes | Safari on iOSFull supportYes | Samsung InternetFull supportYes |
disabled | ChromeFull support1 | EdgeFull support12 | FirefoxFull support1 | Internet ExplorerFull support8 | OperaFull supportYes | SafariFull supportYes | WebView AndroidFull supportYes | Chrome AndroidFull supportYes | Firefox for AndroidFull support4 | Opera AndroidFull supportYes | Safari on iOSFull supportYes | Samsung InternetFull supportYes |
label | ChromeFull support1 | EdgeFull support12 | FirefoxFull support1 | Internet ExplorerFull support5.5 | OperaFull supportYes | SafariFull supportYes | WebView AndroidFull supportYes | Chrome AndroidFull supportYes | Firefox for AndroidFull support4 | Opera AndroidFull supportYes | Safari on iOSFull supportYes | Samsung InternetFull supportYes |
Legend
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
See also
- Other form-related elements:
<form>
,<legend>
,<label>
,<button>
,<select>
,<datalist>
,<option>
,<fieldset>
,<textarea>
,<keygen>
,<input>
,<output>
,<progress>
and<meter>
.