optgroup ElementThe optgroup element is declared by the XHTML 1.1 Forms Module but is not present in the
*W3C XHTML 1.1 Basic Forms Module
Elements in the Forms Module are:form | label | textarea | select | optgroup | option | button | fieldset | legend | input type="button" | input type="checkbox" | input type="file" | input type="hidden" | input type="image" | input type="password" | input type="radio" | input type="reset" | input type="submit" | input type="text"
The optgroup element is used to group a set of
option elements within a
select list.
The mandatory
label
attribute is used to assign a title for the group
which will be visible to the user. Bear in mind, however,
that not all user agents support optgroup so your options
should make sense even if the optgroup
labels are not rendered.
For example:
<label for="animal">Which of these animals do you like best?</label>
<select id="animal" name="animal">
<optgroup label="Mammals">
<option value="1" selected="selected">Hippopotamus</option>
<option value="2">Elephant</option>
<option value="3">Lion</option>
<option value="4">Giraffe</option>
</optgroup>
<optgroup label="Reptiles">
<option value="5">Crocodile</option>
<option value="6">Iguana</option>
<option value="7">Tortoise</option>
<option value="8">Snake</option>
</optgroup>
</select>
This renders as:
For the selection of "Iguana" above, the
name=value pair of animal=6
will be sent to the processing
URI
if the select list data is submitted as part
of an enclosing form.
The label attribute is #REQUIRED on the optgroup element.
optgroup element are listed below:disabled [ type Boolean ]optgroup is initially disabled. The user cannot interact with a disabled control. (Unsupported in IE7 and below for optgroup and option.)label [ type Text - #REQUIRED ]optgroup, to be rendered within the select listoptgroup element are listed below:class [ type NMTOKENS ]id [ type ID ]style [ type CDATA ], from the Style Attribute Module (deprecated)title [ type Text ]xmlns [ type URI - #FIXED 'http://www.w3.org/1999/xhtml' ]dir [ type Enumeration (ltr | rtl) ], from the Bi-directional Text Modulexml:lang [ type LanguageCode ]All attributes in the
Events Attribute Collection
are supported:onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup
optgroup element is:
NOTE: This element cannot be empty
See Content Model & Nesting for information about Content Model syntax and Nesting Groups.
optgroupoptionoptgroupselect