HTML <optgroup> Tag

Description

The <optgroup> HTML element is a container inside which the <option> elements are combined into one group. The peculiarity of <optgroup> is that it does not stand out as a regular list item, it is accented with a bold style, and all elements included in this container are shifted to the right of its original position.

Properties

Permitted Parents
A <select> element
Content
One or more <option> elements
Start/End Tags
Start tag: required, End tag: required

Example

<select>
<optgroup label="Fruits">
<option value="banana">Banana</option>
<option value="orange">Orange</option>
<option value="apple">Apple</option>
</optgroup>
<optgroup label="Vegetables">
<option value="carrot">Carrot</option>
<option value="tomato">Tomato</option>
<option value="onion">Onion</option>
</optgroup>
</select>

Attributes

Attribute Definition
label Specifies a label for the option group.
disabled Disables the input control. The button won't accept changes from the user. It also cannot receive focus and will be skipped when tabbing.

Global Attributes

The <optgroup> tag also supports the Global Attributes in HTML5

Event Attributes

The <optgroup> tag also supports the Event Attributes in HTML5

Browser Support

Desktop
Explorer Edge Chrome Firefox Opera Safari
5.5Yes11YesYes
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
YesYes4YesYesYes

Last updated by CSSPortal on: 6th December 2019