🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
REFERENCEhtml

html Documentation

LOADING ENGINE...

muted

AI & DATA SCIENCE // muted

The muted attribute on <video> or <audio> starts the media with its audio silenced, and is required for autoplay to work in nearly every modern browser.

Syntax

<video autoplay muted>
  <source src="clip.mp4" type="video/mp4">
</video>

Deep Dive Course

**`muted`** is a boolean attribute that silences a `<video>` or `<audio>` element's audio track from the start. Its most important practical use today is enabling `autoplay`: browsers only allow media to autoplay automatically if it's also muted, specifically to prevent unwanted, disruptive sound from playing without a user's action. Users can still unmute manually via the native controls (if `controls` is present) or you can toggle it programmatically with JavaScript (`element.muted = false`), typically in response to a user click.

1Understanding muted

`muted` is a boolean attribute that silences a <video> or <audio> element's audio track from the start. Its most important practical use today is enabling autoplay: browsers only allow media to autoplay automatically if it's also muted, specifically to prevent unwanted, disruptive sound from playing without a user's action. Users can still unmute manually via the native controls (if controls is present) or you can toggle it programmatically with JavaScript (element.muted = false), typically in response to a user click.

💡

Setting muted as an HTML attribute and setting element.muted = true in JavaScript aren't always perfectly interchangeable across all browsers for autoplay purposes — for autoplay specifically, the HTML attribute is the more reliable choice.

editor.html
<video autoplay muted loop>
  <source src="/hero-loop.mp4" type="video/mp4">
</video>
localhost:3000

2Practical Example

Here is a real-world application of muted showing how it is used in production HTML.

editor.html
<!-- Letting the user opt into sound -->
<video id="promo" autoplay muted loop></video>
<button onclick="document.getElementById('promo').muted = false">Unmute</button>
localhost:3000

3Best Practices

Follow these guidelines when working with muted:

1. Add muted whenever you need autoplay to actually work

2. Let users unmute via a visible button or the native controls, rather than forcing silence with no way to enable sound

3. Prefer the HTML muted attribute over only setting the JS property when autoplay is involved

⚠️

Tip: Setting muted as an HTML attribute and setting element.muted = true in JavaScript aren't always perfectly interchangeable across all browsers for autoplay purposes — for autoplay specifically, the HTML attribute is the more reliable choice.

editor.html
<video autoplay muted loop>
  <source src="/hero-loop.mp4" type="video/mp4">
</video>
localhost:3000

Examples

Example 01Basic Usage
<video autoplay muted loop>
  <source src="/hero-loop.mp4" type="video/mp4">
</video>
Example 02Advanced Example
<!-- Letting the user opt into sound -->
<video id="promo" autoplay muted loop></video>
<button onclick="document.getElementById('promo').muted = false">Unmute</button>

Best Practices

  • Add muted whenever you need autoplay to actually work
  • Let users unmute via a visible button or the native controls, rather than forcing silence with no way to enable sound
  • Prefer the HTML muted attribute over only setting the JS property when autoplay is involved

Interview Question

Why is muted specifically required for autoplay to function in most browsers today?

Hint: Think about what browsers are trying to prevent by blocking autoplay with sound.

Browsers implement this restriction to prevent a historically disruptive pattern: pages or ads that blast sound the instant they load, without any user action. By only permitting autoplay when the media is also muted, browsers guarantee that sound can never start without some form of explicit user interaction (like clicking an unmute button afterward), which respects user expectations while still allowing visually autoplaying content like background videos.

Exercises

EasyPractice using muted in a real scenario.
View Solution
<video autoplay muted loop>
  <source src="/hero-loop.mp4" type="video/mp4">
</video>

Frequently Asked Questions

Why is muted specifically required for autoplay to function in most browsers today?

Browsers implement this restriction to prevent a historically disruptive pattern: pages or ads that blast sound the instant they load, without any user action. By only permitting autoplay when the media is also muted, browsers guarantee that sound can never start without some form of explicit user interaction (like clicking an unmute button afterward), which respects user expectations while still allowing visually autoplaying content like background videos.

Related Functions

autoplayvideo-tagaudio-tag