HTML default Attribute

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 3 Examples
Media & Accessibility

What You’ll Learn

The default attribute is a boolean attribute on the <track> element. It tells the browser which text track (subtitles, captions, or other timed text) should be enabled by default on a <video> or <audio> element, unless the user chooses another track. It is not used for form default values.

01

track Element

Where default applies.

02

Boolean

Presence = enabled.

03

Subtitles

Default language track.

04

One Per Kind

Single default rule.

05

JavaScript

track.default property.

06

Not for Forms

Use value, checked.

Purpose of default

When a video or audio element has multiple <track> elements (for example English and Spanish subtitles), the default attribute marks which track the browser should enable when the page loads, if the user’s preferences do not indicate another track is more appropriate.

This helps viewers see captions or subtitles immediately without opening the player menu first. It is especially important for accessibility when you provide multiple language options or both captions and subtitles.

⚠️
Not for form fields

Some older tutorials incorrectly show default="JohnDoe" on <input> elements. That is invalid HTML. For forms, use value, checked, and selected instead.

📝 Syntax

Add default to the <track> element that should load first:

default-track.html
<video controls>

  <source src="movie.mp4" type="video/mp4">

  <track kind="subtitles" src="subs-en.vtt" srclang="en" label="English" default>

  <track kind="subtitles" src="subs-es.vtt" srclang="es" label="Español">

</video>

Syntax Rules

  • Boolean attribute: write default alone or as default="".
  • Only valid on <track> inside <video> or <audio>.
  • Pair with kind, src, srclang, and label on the track.
  • Use at most one default track per kind (subtitles, captions, etc.) per media element.

💎 Values

The default attribute is a boolean attribute. It has no meaningful string values:

  • Attribute present — This track is the default text track for its kind.
  • Attribute absent — The track is available but not enabled by default.
default-boolean.html
<!-- Default English subtitles -->

<track kind="subtitles" src="en.vtt" srclang="en" label="English" default>



<!-- Optional Spanish track (not default) -->

<track kind="subtitles" src="es.vtt" srclang="es" label="Español">

⚡ Quick Reference

ItemDetailsNotes
Element<track>Child of video or audio
TypeBoolean attributePresence = default track
Track fileWebVTT (.vtt)Set in track src
LimitOne default per kindPer media element
JS propertytrackElement.defaultReturns true or false
Form fieldsNot supportedUse value, checked, selected

Applicable Elements

ElementSupported?Notes
<track>YesPrimary and only standard use
<video>, <audio>Parent onlyTrack must be inside media element
<input>, <select>NoUse value, checked, selected
<option>NoUse selected on option

default vs form default values

Beginners often confuse the default attribute with setting initial form values. They are different concepts:

GoalWrong (invalid)Correct
Pre-fill text inputdefault="JohnDoe"value="JohnDoe"
Checked checkboxdefault="true"checked
Pre-selected optiondefault="US" on selectselected on option
Default subtitle trackNot applicabledefault on track

Examples Gallery

Default subtitle tracks on video, JavaScript control, and the correct form attributes beginners should use instead.

Example — Default Subtitle Track

A video with English and Spanish subtitle tracks. English has default so it loads first:

video-tracks.html
<video controls>

  <source src="count.mp4" type="video/mp4">

  <track kind="subtitles" src="count.vtt" srclang="en" label="English" default>

  <track kind="subtitles" src="count_es.vtt" srclang="es" label="Español">

</video>
Try It Yourself

How It Works

The browser loads the track with default when the video starts, unless the user has a language preference that selects another track.

Dynamic Values with JavaScript

You can read or change the default track using the default property on HTMLTrackElement:

track-default-js.html
<script>

  var track = document.getElementById("trackEn");

  console.log(track.default); // true if default attribute is set

  track.default = true;

</script>



<video id="demoVideo" controls>

  <source src="count.mp4" type="video/mp4">

  <track id="trackEn" kind="subtitles" src="count.vtt" srclang="en" label="English" default>

  <track id="trackEs" kind="subtitles" src="count_es.vtt" srclang="es" label="Español">

</video>
Try It Yourself

How It Works

The default property mirrors the boolean attribute. Set it on one track and clear it on others when switching the preferred subtitle language programmatically.

Form Defaults — Use the Right Attributes

For form controls, use standard attributes instead of the non-existent default attribute on inputs:

form-defaults.html
<input type="text" value="JohnDoe">

<input type="checkbox" checked>

<option value="US" selected>United States</option>

How It Works

HTML never defined default for form fields. The default attribute name is reserved for text tracks on media elements only.

♿ Accessibility & UX

  • Enable captions by default — Use default on a captions or subtitles track so deaf and hard-of-hearing users see text immediately.
  • Match user language — Prefer the track that matches the page language or offer multiple labeled tracks.
  • One default per kind — Avoid marking multiple tracks as default for the same kind; browsers may behave unpredictably.
  • Provide kind and label — Clear label text (e.g. “English”, “Español”) helps users pick tracks in the player menu.
  • Do not rely on autoplay alone — Default tracks work with user-controlled playback; pair with controls on video.

🧠 How default Works

1

Author adds track with default

Mark one WebVTT track as the preferred default.

Markup
2

Browser loads media

Video or audio starts; text tracks are registered.

Parse
3

Default track is enabled

Unless user prefs pick another track, default is shown.

Display
=

Accessible media by default

Viewers see subtitles or captions without extra steps.

Browser Support

The default attribute on <track> is supported in all modern browsers that support HTML5 video and text tracks.

HTML5 · Fully supported

Default text tracks in modern media

Chrome, Firefox, Safari, and Edge honor default on track elements paired with video or audio.

97% Browser support
Google Chrome 23+ supported
Full support
Mozilla Firefox 31+ supported
Full support
Apple Safari 6+ supported
Full support
Microsoft Edge Fully supported
Full support
default on track 97% supported

Bottom line: Use default confidently on text tracks in HTML5 media; test with your actual .vtt files.

💡 Best Practices

✅ Do

  • Mark one subtitle or caption track as default for accessibility
  • Use clear label and srclang on every track
  • Serve valid WebVTT files from the same origin or use crossorigin
  • Test track switching in the browser player UI
  • Use value, checked, and selected for form defaults

❌ Don’t

  • Put default on input, select, or textarea elements
  • Mark multiple tracks of the same kind as default
  • Confuse default with the selected attribute on option
  • Forget srclang when kind is subtitles
  • Assume tracks work without a valid src URL

Conclusion

The default attribute is a focused, useful HTML feature for media accessibility. On <track> elements it selects which timed text track loads first on video and audio. It does not set form field values.

When building accessible video, pair default with well-authored WebVTT captions or subtitles. For forms, stick to value, checked, and selected.

Key Takeaways

Knowledge Unlocked

Five truths every developer should know about default

Bookmark these before adding subtitle tracks to video.

5
Core concepts
02

Boolean

Presence = default.

Syntax
💬 03

Subtitles

Default language.

Use case
⚙️ 04

One Per Kind

Single default rule.

Rule
📝 05

Not for Forms

value, checked.

Common mistake

❓ Frequently Asked Questions

On a track element, it marks the text track that should be enabled by default when the media loads, unless the user prefers another track.
<track> inside <video> or <audio>. It is not valid on form controls.
No. Use value for text inputs, checked for checkboxes and radios, and selected on option elements.
Only one track per kind (such as subtitles or captions) on each media element should have the default attribute.
Yes. Use the default property on HTMLTrackElement to read or set whether a track is the default.
Yes. All major browsers that support HTML5 video and text tracks support the default attribute on track elements.

Add accessible default subtitles

Practice the default attribute on English and Spanish tracks in the Try It editor.

Try subtitle track example →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

3 people found this page helpful