The HTML <optgroup> tag
Quick answer
The HTML <optgroup> element groups related <option> elements inside a <select> under a heading set by its label attribute.
Overview
The <optgroup> element organizes a long <select> drop-down into labeled sections, making a big list easier to scan. Its label attribute supplies the section heading.
The heading itself is not selectable — it is a divider, not a choice — and you can disable an entire group at once with the disabled attribute. One structural limit to know: option groups cannot be nested inside one another.
Syntax
<optgroup label="Citrus">
<option>Orange</option>
<option>Lemon</option>
</optgroup>
Attributes
The <optgroup> element supports the following attributes, in addition to the global attributes available to every HTML element.
Example
<select>
<optgroup label="Fruit"><option>Apple</option><option>Pear</option></optgroup>
<optgroup label="Veg"><option>Carrot</option></optgroup>
</select>
Best practices
- Use
<optgroup>to break long drop-downs into labeled, scannable sections. - Set the section heading with the required
labelattribute. - Disable a whole group at once with the
disabledattribute. - Remember option groups cannot be nested — keep the structure one level deep.
Frequently asked questions
How do I group options in a drop-down?
Is the optgroup label selectable?
No. The
label is a non-selectable heading that visually separates the group.Can I nest optgroups?
No. Option groups cannot contain other option groups — the structure is limited to one level.
How do I disable a whole group of options?
Add the
disabled attribute to the <optgroup>; every option inside becomes unavailable.