HTML < optgroup>
query_builder | Christopher PisaniThe HTML element <optgroup> is used to group set of options in a drop-down list.
A simple example to show how it works
Select a town:
<select>
<optgroup label="Eligable towns in Scotland">
<option value="nairn">Nairn</option>
<option value="forres">Forres</option>
<option value="elgin">Elgin</option>
<option value="rothes">Rothes</option>
</optgroup>
<optgroup label="Eligable towns in England">
<option value="liverpool">Liverpool</option>
<option value="manchester">Manchester</option>
<option value="essex">Essex</option>
<option value="kent">Kent</option>
</optgroup>
</select>
Available Attributes
Attribute | Values | Functionality |
---|---|---|
disabled | Disables the entire group in the dropdown list | |
label | text | The title for the group shown in the dropdown list |