optgroup element



Optgroup element is used to categorize the set of options in the drop down list box.
<select> <optgroup label="Text"> <option value="Text">Text</option> <option value="Text">Text</option> </optgroup> </select>
Element Specific attributes supported by this element are:
label text It indicates name/title for the option group.
disabled disabled The entire category will be disabled and also the user cannot choose any option.

Example Code:

Result :

View the Metropolitan cities of India

  • It must be placed inside the <select>.
  • User cannot select or edit the title i.e. label.
  • This element is used to categorize the list of options.
It is available in the previous versions of HTML.
It supports both Global Attributes and Event Attributes in HTML5.


It will function in all the browsers.

Ask Questions

Ask Question