HTML <optgroup> label Attribute

❮ HTML <optgroup> tag

Example

Two option-groups with labels:

<label for="cars">Choose a car:</label>
<select  name="cars" id="cars">
  <optgroup label="Swedish Cars">
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
  </optgroup>
  <optgroup label="German Cars">
    <option value="mercedes">Mercedes</option>
    <option value="audi">Audi</option>
  </optgroup>
</select>
Try it Yourself »

Definition and Usage

The label attribute specifies a label for an option-group.


Browser Support

Attribute
label Yes Yes Yes Yes Yes

Syntax

<optgroup label="text">

Attribute Values

Value Description
text Specifies a label/description for the option-group

❮ HTML <optgroup> tag
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.