docs.rodeo

MDN Web Docs mirror

: The Option Group element

{{HTMLSidebar}} 

The <optgroup> HTML element creates a grouping of options within a {{HTMLElement("select")}}  element.

{{EmbedInteractiveExample("pages/tabbed/optgroup.html", "tabbed-standard")}} 

[!NOTE] Optgroup elements may not be nested.

Attributes

This element includes the global attributes.

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

{{EmbedLiveSample("Examples")}} 

Technical summary

Content categories None.
Permitted content Zero or more `{{HTMLElement("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 `{{HTMLElement("select")}}`  element.
Implicit ARIA role group
Permitted ARIA roles No role permitted
DOM interface `{{domxref("HTMLOptGroupElement")}}` 

Specifications

{{Specifications}} 

Browser compatibility

{{Compat}} 

See also

In this article

View on MDN