Breaking

Sunday, May 12, 2019

HTML optgroup Tag


Example

Group related options with <optgroup> tags:
<select>
  <optgroup label="Swedish Cars">
    <optionvalue="volvo">Volvo</option>
    <optionvalue="saab">Saab</option>
  </optgroup>
  <optgroup label="German Cars">
    <optionvalue="mercedes">Mercedes</option>
    <optionvalue="audi">Audi</option>
  </optgroup>
</select>
Try it Yourself »

Definition and Usage

The <optgroup> is used to group related options in a drop-down list.
If you have a long list of options, groups of related options are easier to handle for a user.

Browser Support

Element
<optgroup>YesYesYesYesYes

Differences Between HTML 4.01 and HTML5

NONE.

Attributes

AttributeValueDescription
disableddisabledSpecifies that an option-group should be disabled
labeltextSpecifies a label for an option-group

Global Attributes

The <optgroup> tag also supports the Global Attributes in HTML.

Event Attributes

The <optgroup> tag also supports the Event Attributes in HTML.

Related Pages

HTML DOM reference: OptionGroup Object

Default CSS Settings

None.

No comments:

Post a Comment