The optgroup tag
The optgroup tag groups the items of a option drop-down list select.
Grouping is needed to give a common title to a certain group of list items. This title is specified in the label attribute of the optgroup tag.
Attributes
| Attribute | Description |
|---|---|
label |
Specifies the text that will be the heading for a group of list items. |
Example
Let's use the optgroup tag to group the list items into two groups:
<select>
<optgroup label="Country 1">
<option>City 1</option>
<option>City 2</option>
</optgroup>
<optgroup label="Country 2">
<option>City 3</option>
<option>City 4</option>
</optgroup>
</select>
:
See also
-
tag
option,
which creates a drop down list item