- HTML Tutorial
- HTML - Home
- HTML - Introduction
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Headings
- HTML - Paragraphs
- HTML - Fonts
- HTML - Blocks
- HTML - Style Sheet
- HTML - Formatting
- HTML - Quotations
- HTML - Comments
- HTML - Colors
- HTML - Images
- HTML - Image Map
- HTML - Iframes
- HTML - Phrase Elements
- HTML - Meta Tags
- HTML - Classes
- HTML - IDs
- HTML - Backgrounds
- HTML Tables
- HTML - Tables
- HTML - Headers & Caption
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML Color Names & Values
- HTML - Color Names
- HTML - RGB
- HTML - HEX
- HTML - HSL
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Picker
- HTML References
- HTML - Cheat Sheet
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - default Attribute
HTML default attribute used to indicate that a track should be enabled unless the user's preferences indicate that another track is more appropriate.
The default can only be used on one 'track' element per media element. If multiple tracks are marked as default, the first one will be used. You can use the default attribute with JavaScript to check whether this attribute present in the media element or not. If present returns true, otherwise it's false.
Syntax
<track default>
Applies On
Below listed element allow using of the HTML default attribute
Element | Description |
---|---|
<track> | HTML <track> tag is used to define the time-based text tracks for a media file. |
Examples of HTML default Attribute
Bellow examples will illustrate the HTML default attribute, where and how we should use this attribute!
Set default subtitle for Video
In the following example, we are going to use the default attribute with the track element to mention default subtitle for video.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML 'default' attribute</title> <style> video { border: 5px solid black; border-radius: 10px; } </style> </head> <body> <!--HTML 'default' attribute--> <h3> Example of the HTML 'default' attribute </h3> <video width="300" controls> <source src= "https://samplelib.com/lib/preview/mp4/sample-20s.mp4"> <track srclang="subtitles" label="english" default> <track srclang="subtitles" label="Hindi" > </video> <p> This is video with two subtitles, with english being default </p> </body> </html>
Set default attribute for audio
Considering the another scenario, where we are going to use the default attribute with the track element of the audio.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML 'default' attribute</title> <style> audio { border: 5px solid black; border-radius: 10px; } </style> </head> <body> <!--HTML 'default' attribute--> <h3> Example of the HTML 'default' attribute </h3> <audio controls> <source src= "https://samplelib.com/lib/preview/mp3/sample-6s.mp3"> <track srclang="subtitles" default> <track srclang="subtitles" > </audio> <p> Here the first subtitle is being default. </p> </body> </html>
Supported Browsers
Attribute | |||||
---|---|---|---|---|---|
default | Yes 18.0 | Yes 10.0 | Yes 31.0 | Yes 6.0 | Yes 15.0 |
To Continue Learning Please Login
Login with Google