HTML default Attribute

Description

The default attribute is a boolean attribute used in conjunction with the <track> tag in HTML. The <track> tag itself is used to specify text tracks for audio or video elements, such as subtitles, captions, descriptions, or chapters, providing users with a way to get more information about the audio/video content they are consuming.

When the default attribute is applied to a <track> element, it indicates that the track should be enabled unless the user's preferences indicate another track is more appropriate. This is particularly useful in scenarios where multiple text tracks are available (for example, subtitles in multiple languages), and one needs to be selected as the default track to display when the audio or video is played.

The default attribute does not require a value to be set; simply including "default" within the <track> tag is sufficient to apply it. Here is an example of how it might be used:

<video controls>
  <source src="movie.mp4" type="video/mp4">
  <track src="english_subtitles.vtt" kind="subtitles" srclang="en" label="English" default>
  <track src="spanish_subtitles.vtt" kind="subtitles" srclang="es" label="Spanish">
</video>

In this example, a video element contains two text tracks for subtitles: one in English and another in Spanish. The default attribute is added to the English subtitles track, making it the default selection. When the video plays, if the user hasn't specified a preference for subtitles, the English subtitles will be displayed automatically.

Syntax

<track src="URL" default>

Values

The default attribute is a boolean attribute, therefore no values are associated with this attribute.

Applies To

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

Example

<video controls>
<source src="images/earth.mp4" type="video/mp4">
<track kind="subtitles" src="english.vtt" default label="English">
<track kind="subtitles" src="french.vtt" label="French">
</video>

Browser Support

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

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

Last updated by CSSPortal on: 28th March 2024