The HTML <optgroup>
tag is used for grouping related options within your select list. This makes it easier for users to comprehend the options when looking at a large list.
<select>
<optgroup label="Australia">
<option value ="sydney">Sydney</option>
<option value ="melbourne">Melbourne</option>
</optgroup>
<optgroup label="New Zealand">
<option value ="cromwell">Cromwell</option>
<option value ="queenstown">Queenstown</option>
</optgroup>
</select>
The following table shows the attributes that are specific to this tag/element.
Attribute | Description |
---|---|
disabled | Disables the group of input controls. The form control won't accept changes from the user. It also cannot receive focus and will be skipped when tabbing.
This is a boolean attribute. If the attribute is present, its value must either be the empty string or a value that is an ASCII case-insensitive match for the attribute's canonical name, with no leading or trailing whitespace (i.e. either Possible values: - [Empty string] - disabled |
label | Specifies a label for the option group. This attribute must be specified. Its value gives the name of the group. |