HTML srclang Attribute

If this site has been useful, we’d love your support! Running this site takes time and resources, and every small contribution helps us keep creating valuable content. Consider buying us a coffee to keep things going strong!

Description

The srclang attribute is an essential component of the <track> element in HTML, specifically designed to enhance media elements like <video> and <audio> with timed text tracks, such as subtitles, captions, descriptions, or chapters. This attribute specifies the language of the track text data, making it pivotal for accessibility, internationalization, and providing a more inclusive multimedia experience for users with diverse linguistic backgrounds.

The value of the srclang attribute must be a valid BCP 47 language tag that represents the language of the track. For example, en for English, es for Spanish, or fr for French. This allows user agents, such as web browsers, to select the appropriate text track according to the user's preferences or system settings, thereby facilitating a more personalized and accessible content consumption experience.

The srclang attribute works in tandem with the kind attribute (which indicates the kind of text track, such as subtitles or captions) and the label attribute (which provides a readable title for the track). Together, these attributes enable content creators to offer multiple text tracks in different languages or for different purposes, significantly enhancing the user's multimedia experience on the web.

Syntax

<track src="URL" srclang="language-code">

Values

  • language-codeTwo letter Language Code, e.g. en, ko, nl, es, etc.

Applies To

The srclang attribute can be used on the following html elements.

Example

<video width="320" height="240" controls>
<source src="images/earth.mp4" type="video/mp4">

<track src="fgsubtitles_en.vtt" kind="subtitles" srclang="en" label="English">
<track src="fgsubtitles_no.vtt" kind="subtitles" srclang="no" label="Norwegian">
</video>

Browser Support

The following table will show you the current browser support for the HTML srclang Attribute.

Desktop
Edge Chrome Firefox Opera Safari
12233112.16
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview
25311461.54.4

Last updated by CSSPortal on: 29th March 2024