Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / HTML

srclang — text track language

The srclang attribute on track identifies the language of text track data using a BCP 47 language tag. It is required for subtitles, including when kind is omitted.

Version: WHATWG HTML Living Standard; index snapshot date recorded separately

Syntax

<track src="…" kind="subtitles" srclang="pl" label="Polski">

The srclang attribute on track identifies the language of the text track data, not the audio track language. Its value must be a valid BCP 47 language tag, such as pl, en, or en-GB. It does not translate content.

The attribute is required when kind is in the subtitles state. This includes omitting kind, because its missing-value default is subtitles. For other track kinds, srclang is optional. A missing attribute or an empty string means the track has no specified language; however, an empty string is not a valid BCP 47 tag.

Do not confuse srclang with src, which identifies the track resource, or label, which supplies a user-readable name. In the example, the document language is en while the track language is pl. Reading the attribute does not require video playback.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>srclang example</title>
<video controls>
  <track id="subtitles" kind="subtitles" srclang="pl" label="Polski"
    src="data:text/vtt,WEBVTT%0A%0A00:00.000%20--%3E%2000:02.000%0ACze%C5%9B%C4%87!%0A">
</video>
<pre id="result"></pre>
<script>
  const track = document.getElementById('subtitles');
  document.getElementById('result').textContent = track.getAttribute('srclang');
</script>
</html>

Result

pl

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources