<optgroup>
HTML <optgroup> (Option Grouping) Tag
Example
<select>
<optgroup label="Group 1">
<option>Option 1.1</option>
</optgroup>
<optgroup label="Group 2">
<option>Option 2.1</option>
<option>Option 2.2</option>
</optgroup>
<optgroup label="Group 3" disabled>
<option>Option 3.1</option>
<option>Option 3.2</option>
<option>Option 3.3</option>
</optgroup>
</select>
Meaning
The <optgroup> element specifies a grouping of items in a selection list defined by option elements so that the menu choices can be presented in a hierarchical menu or similar alternative fashion to improve access through nonvisual browsers.
Notes:
- This element should occur only within the context of a select element.
- The visual presentation of this element may vary slightly between browsers.
- By default, the first option in the
<select>tag will be selected. The user can select another option in the dropdown list.
Version: HTML 4, 4.01, 5
Standard Syntax
<select>
<optgroup label="text">
<option>text</option>
</optgroup>
</select>
Advertisement
Attributes
| Attribute | Value | Description |
|---|---|---|
| disabled | disabled | It's a Boolean attribute specifies that an option-group should be disabled |
| label | text | Specifies a label for an option-group |
Global Attributes
<optgroup> element also supports the Global Attributes in HTML.
Event Attributes
<optgroup> element also supports the Event Attributes in HTML.
By Default CSS Value(s)
None.
Related Tags:
<button>,<datalist>,<fieldset>,<form>,<input>,<label>,<legend>,<meter>,<optgroup>,<option>,<output>,<progress>,<select> and<textarea>