The HTML <optgroup> tag
Definition and Usage
<optgroup>
The label is used to group related options within the <select> element (drop-down list).
If you have a long list of options, using option groups can make it easier for users to handle.
See also:
HTML DOM Reference Manual:OptionGroup Object
Example
Use <optgroup>
Labels are used to group related options:
<label for="cars">Please select a car brand:</label> <select name="cars" id="cars"> <optgroup label="China Car"> <option value="byd">BYD</option> <option value="geely">Geely</option> </optgroup> <optgroup label="German Cars"> <option value="mercedes">Mercedes</option> <option value="audi">Audi</option> </optgroup> </select>
Attribute
Attribute | Value | Description |
---|---|---|
disabled | disabled | Specifies that the option group should be disabled. |
label | Text | Specifies the tag for the option group. |
Global Attributes
<optgroup>
The tag also supports Global Attributes in HTML.
Event Attributes
<optgroup>
The tag also supports Event Attributes in HTML.
Default CSS Settings
None.
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |