Dofactory.com
Dofactory.com
Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

HTML <optgroup> label Attribute

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.

Example

#

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>

Using label

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.


Syntax

<optgroup label="text">

Values

#

Value Description
text Title of the option group.

Browser support

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

You may also like

 Back to <optgroup>

Last updated on Sep 30, 2023

Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

Guides