Name

optgroup — HTML 4.01 | HTML5

Synopsis

<optgroup> . . . </optgroup>

Defines a logical group of option elements within a select menu form control. An optgroup element may not contain other optgroup elements (they may not be nested).

Start/End Tags

HTML 4.01 and XHTML: Required/Required; HTML5: Required/Optional

Attributes

Core, Internationalization, Events, HTML5 Global Attributes

disabled (disabled="disabled" in XHTML)

Indicates that the group of options is nonfunctional. It can be reactivated with a script.

label="text"

Required. Specifies the label for the option group.

Example

<p>What are your favorite ice cream flavors?<p>
<select name="ice_cream" size="6" multiple="multiple">
<optgroup label="traditional">
   <option>Vanilla</option>
   <option>Chocolate</option>
</optgroup>
<optgroup label="specialty">
   <option>Inside-out Rocky Road</option>
   <option>Super-duper Praline Pecan Smashup</option>
</optgroup>
</select>

Get HTML & XHTML Pocket Reference, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.