HTML group of options - how to use <optgroup> tag

The HTML <optgroup> tag is used to define a group of options within a dropdown list.

Attributes

The optgroup tag supports the global and event attributes.

disabled
Renders the option group as disabled
label
Defines a label for the option group

Examples:

<select> <optgroup label="American cities"> <option value="New York">New York</option> <option value="Washington">Washington</option> </optgroup> <optgroup label="Chinese cities"> <option value="Beijing">Beijing</option> <option value="Shanghai">Shanghai</option> </optgroup> <optgroup label="Australian cities"> <option value="Sydney">Sydney</option> <option value="Melbourne">Melbourne</option> </optgroup> </select>

Related HTML tags and useful links: