Advertisement
Home Open Editor ❯

HTML <optgroup> label Attribute

Example

<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">
    <option>Option 3.1</option>
    <option>Option 3.2</option>
    <option>Option 3.3</option>
  </optgroup>
</select>

Try this code ❯

Meaning

The label attribute contains a short label to use when the selection list is rendered as items in a hierarchy.

The browser can use when labeling the options in the user interface.

Note: This attribute is mandatory if this element is used.


Standard Syntax

<select>
  <optgroup label="text">
    <option>text</option>
  </optgroup>
</select>


Advertisement

Attribute Values

Value Description
text Specifies a label for the option-group
Home Open Editor ❯
Advertisement