From http://www.w3schools.com (Copyright Refsnes Data)

HTML <optgroup> tag


Example

Group together related options with <optgroup> tags:

<select>
  <optgroup label="Swedish Cars">
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
  </optgroup>
  <optgroup label="German Cars">
    <option value="mercedes">Mercedes</option>
    <option value="audi">Audi</option>
  </optgroup>
</select>

Try it yourself!


Definition and Usage

The <optgroup> tag is used to group together related options in a select list.

If you have a long list of options, groups of related options are easier to handle for the user.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The <optgroup> tag is supported in all major browsers.


Differences Between HTML and XHTML

NONE


Required Attributes

DTD indicates in which DTD the attribute is allowed. S=Strict, T=Transitional, and F=Frameset.

Attribute Value Description DTD
label text Specifies a description for a group of options STF

Optional Attributes

Attribute Value Description DTD
disabled disabled Specifies that an option group should be disabled STF

Standard Attributes

id, class, title, style, dir, lang, xml:lang, tabindex

For a full description, go to Standard Attributes.

Event Attributes

onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup

For a full description, go to Event Attributes.


From http://www.w3schools.com (Copyright Refsnes Data)