You are here: Reference > HTML > tags > optGroup

optGroup element

Browser support:
Defines a group of option elements in a select form field.
The optgroup element is used to group option elements in a select element.
If you want to see the HTML tags by categories, please visit this page.
This element requires a closing tag.
JavaScript page for this element: optGroup.

Possible members:

Attributes
Events
Styles
Pseudos
accessKey
Sets an access key to an element.
class
Sets the style class or classes that belong to the element.
contentEditable
3
Sets whether the contents of the object are editable.
dir
Sets the text direction as related to the lang attribute.
DISABLED
8
Sets the state of an object for user interaction.
id
Sets a unique identifier for the object.
label
Sets the text to show as the contents of the option group element.
lang
Specifies the language of the element.
language
Sets the scripting language for the current element. Use it only for the script element.
name
Sets the name of an element.
style
Sets an inline style associated with an element.
tabIndex
Specifies the tabbing order for keyboard navigation using the TAB key.
title
Specifies a tooltip for an element.
xml:lang
Sets the language code of the XML document.

Example HTML code 1:

This example illustrates the use of the optGroup element:
<select>
    <option selected="selected" value="none">None</option>
    <optgroup label="Fruits">
        <option value="Apple">Apple</option>
        <option value="Pear">Pear</option>
        <option value="Peach">Peach</option>
    </optgroup>
    <optgroup label="Vegetables">
        <option value="Bean">Bean</option>
        <option value="Cole">Cole</option>
    </optgroup>
</select>
Did you find this example helpful? yes no

Related pages:

External links:

User Contributed Comments

Post Content

Post Content