HTML optgroup tag
HTML

HTML optgroup tag

Editorial Team
Editorial Team

Follow us on Discord or Telegram to get access to free tutorials and updates.

The HTML optgroup tag is used to group options within inside a <select> tag.

Attributes

AttributeDescriptiondisabledThis boolean attribute is used to specify ehether the element is disabled.labelUsed to specify a label for each groups.

Example

<select id="lang">
    <optgroup label="Compiled">
        <option>C</option>
        <option>C++</option>
        <option>C#</option>
    </optgroup>
    <optgroup label="Interpreted">
        <option>PHP</option>
        <option>JavaScript</option>
    </optgroup>
</select>

Output