This <optgroup> element groups multiple options within a <select> element list together. The option groups cannot be nested within other option groups.
<optgroup> |
Yes | Yes | Yes | Yes | Yes |
None.
Attribute | Value | Description |
---|---|---|
disabled | disabled | diable an option-group |
label | text | Set a label for an option-group |
The <optgroup> tag supports the Global Attributes in HTML.
The <optgroup> tag supports the Event Attributes in HTML.
None.
A demo showing how to use <optgroup> tag.
<html>
<body>
<form>
<select name="select1">
<optgroup label="First Group">
<option>First</option>
<option>second</option>
<option>third</option>
</optgroup>
<optgroup label="Second Group">
<option>First item in second group</option>
<option>Second item in second group</option>
<option>Third item in second group</option>
</optgroup>
</select>
</form>
</body><!-- w w w.j av a2 s. co m-->
</html>