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
Example
Browser Support
The following information will show you the current browser support for the HTML default attribute. Hover over a browser icon to see the version that first introduced support for this HTML attribute.
This attribute is supported by all modern browsers.
Desktop
Tablets & Mobile
Last updated by CSSPortal on: 28th March 2024
