HTML <optgroup> Tag

Advertisements


Description

The HTML <optgroup> tag is used for grouping related options within your select list. This makes it easier for users to comprehend their choices when looking at a large list.

Example

<!DOCTYPE html>
<html>
<head>
<title>HTML optgroup Tag</title>
</head>
<body>
<select>
<optgroup label="India">
  <option value ="mumbai">Mumbai</option>
  <option value ="delhi">Delhi</option>
</optgroup>
<optgroup label="USA">
  <option value ="florida">Florida</option>
  <option value ="newyork">New York</option>
</optgroup>
</select>
</body>
</html>

This will produce following result:

Global Attributes

This tag supports all the global attributes described in - HTML Attribute Reference

Specific Attributes

The HTML <optgroup> tag also supports following additional attributes:

AttributeValueDescription
disableddisabledDisables the input control. The button won't accept changes from the user. It also cannot receive focus and will be skipped when tabbing.
labeltextDefines a label to use when using <optgroup>.

Event Attributes

This tag supports all the event attributes described in - HTML Events Reference

Browser Support

ChromeFirefoxIEOperaSafariAndroid
YesYesYesYesYesYes

html_tags_reference.htm