👀 Live Preview
A video with English and Spanish subtitle tracks identified by srclang:
Use the player’s captions/subtitles menu to switch languages.

The srclang attribute is an essential HTML feature associated with the <track> element. It specifies the language of a text track file—such as subtitles or captions—so browsers and media players can label tracks correctly and help users pick the language they understand.
Accurate language metadata improves accessibility for deaf and hard-of-hearing viewers (captions), non-native speakers (subtitles), and anyone using assistive technology. It is especially important for multilingual videos with several track files.
Only element.
en, es, fr.
Translation.
Accessibility.
User menu.
.srclang property.
srclangThe primary purpose of the srclang attribute is to define the language of the track file linked by <track src>. When a video offers subtitles in English and Spanish, each <track> needs its own srclang value so the player can list “English” and “Spanish” accurately and match user language preferences where possible.
This attribute is particularly important for multimedia accessibility. Captions and subtitles are often stored as WebVTT (`.vtt`) files; srclang tells the browser what language those cues are written in, separate from the spoken audio language of the video.
srclang identifies language; kind says whether the track is subtitles, captions, descriptions, chapters, or metadata; label is the human-readable name shown in the player menu.
Add srclang on <track> inside <video> or <audio>:
<video controls>
<source src="example.mp4" type="video/mp4">
<track
src="subtitles_en.vtt"
kind="subtitles"
srclang="en"
label="English">
<track
src="subtitles_es.vtt"
kind="subtitles"
srclang="es"
label="Spanish">
</video><track> (child of video or audio).kind is subtitles or captions.en-US or pt-BR are also valid.label so users see a friendly name in the caption menu.default on one track to enable it initially when supported.The srclang attribute accepts language codes. Common examples:
srclang="en" — English.srclang="es" — Spanish.srclang="fr" — French.srclang="de" — German.srclang="ja" — Japanese.srclang="en-US" — English (United States) using BCP 47.These codes help browsers and media players identify and display the correct language for track content. Use standard tags from BCP 47 for consistency.
<track src="captions_en.vtt" kind="captions" srclang="en" label="English CC">
<track src="subtitles_fr.vtt" kind="subtitles" srclang="fr" label="Français">| Topic | Detail | Example |
|---|---|---|
| Element | <track> only | Inside video/audio |
| Value | Language tag | en, es |
| Required when | kind is subtitles/captions | Always set |
| Track file | WebVTT (.vtt) typical | src="file.vtt" |
| User menu | label attribute | label="English" |
| JavaScript | track.srclang = "fr" | Runtime update |
| Element | Supported? | Notes |
|---|---|---|
<track> | Yes | Primary and only use of srclang |
<video> | Parent | Contains track elements |
<audio> | Parent | Can include tracks for captions |
<source> | No | Uses src, not srclang |
<img>, <script> | No | Different attributes |
srclang vs lang vs label| Attribute | On | Purpose |
|---|---|---|
srclang | track | Language of the .vtt track file |
lang | Any element (global) | Language of element’s text content |
label | track | Display name in player menu |
kind | track | subtitles, captions, chapters, etc. |
Multilingual subtitles, dynamic srclang updates, and accessible captions on <track>.
A video with English and Spanish subtitle tracks identified by srclang:
Use the player’s captions/subtitles menu to switch languages.
Two <track> elements with different srclang values:
<video controls>
<source src="example.mp4" type="video/mp4">
<track src="subtitles_en.vtt" kind="subtitles" srclang="en" label="English">
<track src="subtitles_es.vtt" kind="subtitles" srclang="es" label="Spanish">
</video>Each track points to a separate WebVTT file. srclang="en" and srclang="es" tell the player which language each file contains, so users can choose English or Spanish subtitles.
Update track language metadata at runtime:
<track id="dynamicTrack" src="subs.vtt" kind="subtitles" srclang="en" label="Track">
<script>
document.getElementById("dynamicTrack").srclang = "fr";
</script>In this script, srclang is set to fr on the track element. For full language switching you often swap the track src file or add/remove tracks rather than only changing the attribute.
Use kind="captions" with srclang for accessible closed captions:
<track
src="captions_en.vtt"
kind="captions"
srclang="en"
label="English captions"
default>Captions differ from subtitles: they include non-speech audio cues for accessibility. srclang still identifies the written language of the caption file.
kind="captions" with correct srclang for deaf and hard-of-hearing users.srclang to the language actually used in the VTT file.label text users understand (e.g. “English”, “Español”).VTT file + srclang.
Parses WebVTT file.
label + srclang shown.
Right language track.
The srclang attribute on <track> is supported in all modern browsers with HTML5 video.
Chrome, Firefox, Safari, and Edge support track with srclang.
Bottom line: Use srclang on every subtitles/captions track in modern HTML5 video.
srclang on every subtitles and captions tracklabel textsrclangsrclang on required track kindssrclang with page langThe srclang attribute is a crucial tool for enhancing the accessibility and user experience of multimedia content in HTML. By accurately specifying the language of track files, you help users find subtitles and captions in the language they need.
Combine srclang with kind, label, and well-authored WebVTT files to build inclusive, multilingual video experiences on the web.
srclangBookmark these before publishing video with tracks.
VTT metadata
PurposeOne element
ScopeLanguage tags
ValuesDynamic update
DynamicAccessibility
A11y<track>, such as subtitles or captions in WebVTT format.<track> element, used inside <video> or <audio>.en, es, and fr, or BCP 47 tags like en-US.kind is subtitles or captions. Always include it for those track types.track.srclang at runtime. For full language switching, update or replace track elements as needed.<track> elements.Practice srclang on subtitle and caption tracks in the Try It editor.
5 people found this page helpful