The label attribute on an <optgroup> tag specifies a label or title for the optgroup element.
The label value will display instead of the longer text version.
A label attribute on <optgroup> elements.
The labels are the titles of the option groups.
<select>
<option value="">-- Select City --</option>
<optgroup label="Europe">
<option value="stockholm">Stockholm</option>
<option value="barcelona">Barcelona</option>
<option value="athens">Athens</option>
</optgroup>
<optgroup label="Asia">
<option value="bangkok">Bangkok</option>
<option value="manila">Manila</option>
<option value="jakarta">Jakarta</option>
</optgroup>
</select>
The label attribute specifies the label for an option group.
This label will be used as the option group's title or category of the option.
<optgroup label="text">
Value | Description |
---|---|
text | Title of the option group. |
Here is when label support started for each browser:
Chrome
|
1.0 | Sep 2008 |
Firefox
|
1.0 | Sep 2002 |
IE/Edge
|
1.0 | Aug 1995 |
Opera
|
1.0 | Jan 2006 |
Safari
|
1.0 | Jan 2003 |
Back to <optgroup>