You are here: Reference > HTML > attributes > label (optgroup)

label attribute (optgroup)

Browser support:
Sets the text to show as the contents of the option group element.
The displayed text is unselectable in the drop-down list (select), it is useful for grouping the list items.
JavaScript page for this attribute: label. You can find other example(s) there.

Possible values:

String that sets the label of the group.
Default: this attribute has no default value.

Example HTML code 1:

This example illustrates the use of the label attribute:
<select id="mySelect" size="8">
    <option selected="selected">None</option>
    <optgroup label="Fruits">
        <option />Apple
        <option />Pear
        <option />Peach
    <optgroup label="Vegetables">
        <option />Bean
        <option />Cole
Did you find this example helpful? yes no

Supported by tags:

External links:

User Contributed Comments

Post Content

Post Content