Last Updated on April 26, 2023 by Roshan Parihar
HTML optgroup tag is used to show select options in groups inside the form elements.
The option tag is used inside optgroup for the grouping options.
Syntax
1 |
<optgroup>put here grouping options</optgroup> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<select> <optgroup label="HTML"> <option>HTML form tag</option> <option>HTML Table tag</option> </optgroup> <optgroup label="Java"> <option selected="selected">Inheritance</option> <option>Polymorphism</option> </optgroup> <optgroup label="HTML5" disabled="disabled"> <option>HTML header tag</option> <option>HTML footer tag</option> </optgroup> </select> |
Output
List of HTML optgroup tag attributes
Sr. No. | attribute options | Description |
---|---|---|
1 | label | This attribute used to specify the label of options. The value of this can be any text. |
2 | disabled | This attribute used to disable group all the options. This makes grouped options not selectable.The value for this is disabled. |
Resources and References
1. W3C Specification.
2. HTML living standard
3. W3C project using Github