HTML - srclang Attribute



The srclang attribute is an HTML attribute that is used to specify the language of the track text. And the srclang attribute applied within the <track> element.

This attribute is used to specify the language of the text data and it is of valid language tag. If the kind attribute is set to subtitles (kind="subtitles"), then srclang must be defined.

Syntax

Following is the syntax of the HTML srclang attribute −

<track src=" " kind="subtitles" srclang="language_code" >

Language_code − it defines a two-letter language code which specify the language of the track text.

Example

In the following example, we are illustrating the use of the srclang attribute along with the kind attribute within the <track> element to specify the language of the subtitle, as follows−

<html>
<head>
   <title>HTML Track srclang Attribute</title>
</head>
<body>
   <h1 style="color: green;">tutorials <span style="color: black">point</span>
   </h1>
   <h2>HTML Track srclang Attribute</h2>
   <video width="350" height="200" controls>
   <track src="https://www.dropbox.com/s/xvjem6er1pp1usy/MicrosoftInclusiveHiring.mp4?raw=1" id="myTrack1" kind="subtitles" srclang="en" label="English">
   <source id="myTrack" src="https://www.dropbox.com/s/xvjem6er1pp1usy/MicrosoftInclusiveHiring.mp4?raw=1" type="video/mp4">
   </video>
</body>
</html>

On running the above code, the output window will pop up displaying the video on the webpage.

html_attributes_reference.htm
Advertisements