HTML label Attribute

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 3 Examples
Media & Accessibility

Introduction

The label attribute is used on the <track> element to provide a user-readable title for a text track. When someone opens the captions or subtitles menu in a video player, they see each track’s label—for example, “English Captions” or “Español”. Text tracks work with <video> and <audio> to show synchronized captions, subtitles, descriptions, and chapter markers.

What You’ll Learn

01

<track> Label

Menu-visible title.

02

String Value

Plain text only.

03

label vs srclang

UI name vs code.

04

Multi-Language

Distinct track names.

05

Not <label>

Attribute vs element.

06

JS label

Update at runtime.

Purpose of label

The primary purpose of the label attribute is to give each text track a clear, human-readable name in the media player UI. Without meaningful labels, users cannot tell which track is English captions, which is Spanish subtitles, or which is an audio description.

The label works together with kind (track type), srclang (language code), and src (WebVTT file). While srclang tells machines the language, label is what people actually read when choosing a track.

💡
Not the <label> form element

HTML also has a <label> element for forms, which uses the for attribute to link to inputs. This tutorial covers the label attribute on <track> only.

📝 Syntax

Add label on a <track> element inside <video> or <audio>:

label.html
<video controls>
  <source src="video.mp4" type="video/mp4">
  <track
    src="captions_en.vtt"
    kind="captions"
    srclang="en"
    label="English Captions"
    default>
</video>

Syntax Rules

  • Valid only on <track> elements inside <video> or <audio>.
  • Value is a plain text string—no HTML tags inside the attribute.
  • For subtitles, captions, and descriptions tracks, provide a non-empty label so users can select the track.
  • Make each label unique when multiple tracks share the same language or kind.
  • Pair with kind, src, and srclang for a complete text track.
  • Write labels in the language users expect (e.g. “Español” rather than “es”).

💎 Values

The label attribute accepts any user-readable text string. Common patterns include:

  • label="English Captions" — Language plus track type for clarity.
  • label="Español" — Language name when the kind is obvious from context.
  • label="English CC" — Short form for closed captions.
  • label="Audio description" — Describes a kind="descriptions" track.
  • label="Chapters" — Navigation markers for long videos.

In JavaScript, read or set the property on the track element:

label-js.html
document.querySelector("track").label = "Updated Track Label";

⚡ Quick Reference

Use CaseExample labelNotes
English captionsEnglish CaptionsPair with kind="captions"
Spanish subtitlesEspañolsrclang="es"
Two English tracksEnglish CC vs English SDHLabels must differ
Audio descriptionAudio descriptionkind="descriptions"
Chapter listChapterskind="chapters"
JavaScripttrack.label = "..."DOM property

Applicable Elements

Element / ContextSupported?Notes
<track> in <video>YesPrimary use case
<track> in <audio>YesLyrics, transcripts
<label> form elementNoUses for, not a label attribute
<input>, <option>NoDifferent labeling patterns

label vs srclang

Featurelabelsrclang
PurposeUser-visible menu textMachine-readable language tag
Example valueEnglish Captionsen
Shown in player UIYesUsually hidden
FormatFree textBCP 47 (e.g. en-US)
Both needed?Yes—use together on the same <track>

Examples Gallery

A single captions track, multiple labeled language options, and updating label with JavaScript.

👀 Live Preview

Open the CC menu to see the track label in the player:

The menu shows English Captions from label="English Captions", not the raw srclang="en" code.

Example — Captions Track with Label

Here’s an example of how the label attribute is used within the <track> element:

label.html
<video controls>
  <source src="video.mp4" type="video/mp4">
  <track
    src="captions_en.vtt"
    kind="captions"
    srclang="en"
    label="English Captions">
</video>
Try It Yourself

How It Works

The <track> loads captions_en.vtt. The label does not affect the file content—it only names the track in the UI so users know what they are enabling.

Example — Multiple Tracks with Distinct Labels

When offering several languages, give each track a unique, readable label:

label-multiple.html
<video controls>
  <source src="movie.mp4" type="video/mp4">
  <track kind="captions" src="movie-en.vtt" srclang="en" label="English Captions" default>
  <track kind="subtitles" src="movie-es.vtt" srclang="es" label="Español">
  <track kind="subtitles" src="movie-fr.vtt" srclang="fr" label="Français">
</video>
Try It Yourself

How It Works

All three tracks share the same parent video but differ in label, srclang, and src. The browser uses labels as the primary display text in the track picker.

Dynamic Values with JavaScript

Update a track’s label when user preferences or locale change:

dynamic-label.html
<video controls>
  <source src="clip.mp4" type="video/mp4">
  <track id="dynamicTrack" kind="captions" src="clip.vtt" srclang="en" label="English">
</video>

<script>
  var trackElement = document.getElementById("dynamicTrack");
  trackElement.label = "Updated Track Label";
</script>
Try It Yourself

How It Works

The DOM property label on HTMLTrackElement mirrors the content attribute. Changing it updates what users see without reloading the WebVTT file.

♿ Accessibility

  • Write descriptive labels — “English Captions” is clearer than “Track 1” or “en”.
  • Distinguish track types — When offering both captions and subtitles, include the type in the label (e.g. “English CC” vs “English Subtitles”).
  • Use the user’s language in the label — Show “Français” for French tracks, not only the ISO code.
  • Keep labels unique — Duplicate labels confuse users choosing between similar tracks.
  • Do not skip labels on user-facing tracks — Captions, subtitles, and descriptions need non-empty labels.
  • Form labels are separate — Use the <label for="id"> element for inputs; that is unrelated to the track label attribute.

🧠 How label Works

1

Author sets label on track

Human-readable menu text.

Markup
2

Browser loads text tracks

WebVTT cues from src.

Parse
3

Player builds track menu

Shows each label string.

UI
=

User picks the right track

Clear names improve accessibility.

Browser Support

The label attribute on <track> is supported in all modern browsers alongside HTML5 media elements. Track labels appear in native caption menus in Chrome, Firefox, Safari, and Edge.

HTML5 · Widely supported

Track labels in media players

Modern browsers display label text when users choose captions or subtitles.

97% Browser support
Google Chrome Fully supported
Full support
Mozilla Firefox Fully supported
Full support
Apple Safari Fully supported
Full support
Microsoft Edge Fully supported
Full support
Internet Explorer IE 10+
Partial
Opera Fully supported
Full support
label on <track> 97% supported

Bottom line: Always set clear label values on user-visible text tracks for every supported browser.

💡 Best Practices

✅ Do

  • Provide meaningful labels for every captions/subtitles track
  • Make labels unique when multiple tracks exist on one video
  • Include track type in the label when helpful (CC, SDH, Subtitles)
  • Pair label with accurate srclang and kind
  • Write labels in the language users expect to read

❌ Don’t

  • Confuse the track label attribute with the <label> form element
  • Use opaque names like “Track 1” or raw language codes alone
  • Duplicate the same label on two different tracks
  • Leave labels empty on user-facing caption tracks
  • Embed HTML markup inside the label string

Conclusion

The label attribute within the <track> element is a valuable tool for providing descriptive names to text tracks associated with media elements. It is what users see when they choose captions, subtitles, or other synchronized text in the player.

By utilizing meaningful, unique labels alongside kind and srclang, you enhance the accessibility and user experience of your multimedia content.

Key Takeaways

Knowledge Unlocked

Five truths every developer should know about label

Bookmark these before adding captions to video.

5
Core concepts
📝 02

Plain text

Free-form string

Syntax
🌐 03

Not srclang

UI vs language code

Compare
📄 04

Unique names

Per track on video

Multi-track
05

Not <label>

Attribute vs element

Forms

❓ Frequently Asked Questions

The label attribute applies to <track> elements inside <video> or <audio>. It is not used on the <label> form element.
Any plain text string, such as English Captions or Español. It should be human-readable and unique among tracks on the same media element.
srclang is a BCP 47 language code for machines (e.g. en). label is the friendly name shown in the player menu (e.g. English Captions).
For subtitles, captions, and descriptions tracks, the label must be a non-empty string so users can identify and select the track.
Yes. Set trackElement.label = "Updated Track Label" on the HTMLTrackElement. Prefer setting labels in HTML when possible.
No. The <label> element labels form controls using the for attribute. The label attribute on <track> names text tracks in media players.

Name your text tracks clearly

Practice the label attribute on <track> elements and see how labels appear in the captions menu.

Try captions label example →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful