Example Group together related options with <optgroup> tags: <select> <optgroup label="Swedish Cars...
Example
Group together related options with <optgroup> tags:<select> <optgroup label="Swedish Cars"> <option value="volvo">Volvo</option> <option value="saab">Saab</option> </optgroup> <optgroup label="German Cars"> <option value="mercedes">Mercedes</option> <option value="audi">Audi</option> </optgroup> </select> |
Definition and Usage
The <optgroup> tag is used to group together related options in a select list.If you have a long list of options, groups of related options are easier to handle for the user.
Browser Support
The <optgroup> tag is supported in all major browsers.
Differences Between HTML and XHTML
NONERequired Attributes
DTD indicates in which DTD the attribute is allowed. S=Strict, T=Transitional, and F=Frameset.Attribute | Value | Description | DTD |
---|---|---|---|
label | text | Specifies a description for a group of options | STF |
Optional Attributes
Attribute | Value | Description | DTD |
---|---|---|---|
disabled | disabled | Specifies that an option group should be disabled | STF |
Standard Attributes
id, class, title, style, dir, lang, xml:lang, tabindex |
Event Attributes
onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup |