HTML optgroup Tag

HTML<optgroup>Tag: The HTML<optgroup> groups all the related options in a drop-down list. If you have a long list of options, groups of related options are easier to handle for a user.

HTML<optgroup>Tag

This HTML optgroup tag supports both the global and the event attributes.

Syntax: <optgroup> Text </optgroup>

Attributes

  • label
  • Disabled

Browser Compatibility

The HTML optgroup tag is supported by different types of browsers.

  • Chrome
  • Firefox
  • Opera
  • Safari
  • Internet Explorer

Example:

<!DOCTYPE html>
<html>
<body>
<select>
  <optgroup label="HTML">
    <option value="HTML">HTML</option>
    <option value="CSS">CSS</option>
  </optgroup>
  <optgroup label="JAVA">
    <option value="JAVA">JAVA</option>
    <option value="C">C</option>
  </optgroup>
</select>
</body>
</html>

Output:

HTML optgroup tag

Attributes that are supported by the <optgroup> tag

Attribute Value Description
disabled disabled Describes that an option-group must be deleted
label text Describes a label for an option-group

Global and event attributes

This HTML tag supports all global and event attributes.