HTML label Attribute

The label attribute provides a title for a <track>. It is also used to create a shorter version of the text in an <option>, and also as the title of an <optgroup>.



A label attribute on a <track> element.
The text track is labeled Spanish subtitle.

<video controls="controls" width="320" height="176">
  <source src="/media/godfather.mp4" type="video/mp4" />
  <source src="/media/godfather.ogg" type="video/ogg" />
  <track src="/media/" kind="subtitles" srclang="es" label="Spanish subtitle" />

For additional details see our HTML track label Reference.

Using label

The label attribute specifies an additional description about the element.

For a <track> element, the label specifies the text track title.

For an <option> element, the label is used as shorter version of the text.

For an <optgroup> element, the label is used as the title of the group.


<tagname label="text">



Value Description
text Title of a track or short label of the text.

Elements that accept label

The following elements accept the label attribute.

Elements Description
<track> Adds a text tack -- see example above
<option> Specifies a dropdown option.
<optgroup> Groups related options inside the dropdown.

<option> with label

An <option> tag with a label attribute.
The shorter label value is displayed rather than the option content.

  <option>-- Select Country --</option>
  <option value="1" label="USA">United States of America</option>
  <option value="2" label="UK">United Kingdom</option>
  <option value="3" label="UAE">United Arab Emirates</option>

For additional details see our HTML option label Reference.

<optgroup> with label

Two <optgroup> tags with a label attribute.
The label values are the titles of the option groups.

  <option value="">-- Select City --</option>
  <optgroup label="Europe">
    <option value="stockholm">Stockholm</option>
    <option value="barcelona">Barcelona</option>
    <option value="athens">Athens</option>
  <optgroup label="Asia">
    <option value="bangkok">Bangkok</option>
    <option value="manila">Manila</option>
    <option value="jakarta">Jakarta</option>

For additional details see our HTML optgroup label Reference.

Browser support

Here is when label support started for each browser:

23.0 Nov 2012
31.0 Jul 2014
10.0 Sep 2012
12.1 Nov 2012
6.0 Jul 2012

You may also like