Defines an option group. This
element allows you to group choices. When you have a long list of
options, groups of related choices are easier to handle.
Examples
This code:
Produces this output:
<select>
<optgroup label="Swedish Cars">
<option value ="volvo">Volvo
<option value ="saab">Saab
</optgroup>
<optgroup
label="German Cars">
<option value ="mercedes">Mercedes
<option value ="audi">Audi
</optgroup>
</select>
W3Schools is for training only. We do not warrant its correctness or its fitness for use.
The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our
terms of use and
privacy policy.