HTML optgroup element
HTML <optgroup> tag groups all the option elements under a common name. We have to select one out of these options.
<p>Choose the course you would like to teach.</p> <optgroup label="Chemistry"> <option value="1"> Organic chemistry <option value="2"> Inorganic chemisry <option value="3"> Applied chemistry <optgroup></>
Choose the course you would like to teach.
Here, the value of the label attribute in optgroup starting tag serves as the title of a group of options.
The end tag of <optgroup> element may be omitted.
All the global attributes are applicable on the optgroup element.
Was this article helpful?