References

Beginner-friendly references for web development, with live, editable examples.

The HTML muted attribute

Attribute All modern browsers Updated
In short

The HTML muted attribute makes an <audio> or <video> element start with its sound off. It is a boolean attribute that sets only the initial state, so viewers can still unmute through the controls. Browsers generally let muted media autoplay, which is why MDN's autoplay guide pairs muted with autoplay.

Overview

The muted attribute starts an audio or video element with its sound turned off. It is a boolean attribute of <video> and <audio>, so the bare word is enough, and the HTML Standard defines it as the default value for muting.

The attribute only sets the starting state. Once a script assigns the muted property or the viewer clicks the speaker icon, the attribute has no further effect, and it stays in the markup even while sound plays. In JavaScript, defaultMuted reflects the attribute and muted reports whether the element is muted right now.

Most people reach for muted because of autoplay. Browsers usually block media that would play sound before the viewer interacts with the page, but MDN's autoplay guide notes that the block is not applied when the audio track is muted.

To autoplay a video that has an audio track, MDN's guide says to mute it by default with autoplay muted, and it notes that Safari also needs playsinline. Unmuting from script without a click can pause the element again, because the HTML Standard lets a browser pause media that is no longer allowed to play.

Syntax

<video src="intro.mp4" autoplay muted loop playsinline></video>

Values

Value
A boolean attribute: present or absent.

Example

Live example
<video id="clip" src="https://codeshack.io/web/example.mp4" width="300" autoplay muted loop playsinline controls></video>
<p><button type="button" id="toggle">Unmute</button> <output id="state"></output></p>
<script>
  const clip = document.getElementById('clip');
  const state = document.getElementById('state');
  const show = () => {
    state.textContent = 'muted: ' + clip.muted + ', defaultMuted: ' + clip.defaultMuted;
  };
  document.getElementById('toggle').addEventListener('click', (e) => {
    clip.muted = !clip.muted;
    e.target.textContent = clip.muted ? 'Unmute' : 'Mute';
  });
  clip.addEventListener('volumechange', show);
  show();
</script>

Best practices

  • Pair muted with autoplay and playsinline when a video has to start on its own, and keep controls so viewers can turn the sound on.
  • Toggle sound with the muted property in JavaScript. Removing the attribute stops working once the viewer or a script has changed the mute state.
  • Handle the promise returned by play() when a script unmutes and plays, because a browser that does not allow playback in the current context rejects it with a NotAllowedError.
  • Add captions with a <track> element, so a video that starts silent still gets its spoken words across.

Accessibility

Starting muted keeps autoplay clear of WCAG success criterion 1.4.2. That criterion asks for a pause, stop or volume control whenever audio plays automatically for more than 3 seconds, and a muted element plays no audio at all.

Motion is judged separately. Under criterion 2.2.2, a video that starts on its own, runs longer than five seconds and appears alongside other content needs a way to pause, stop or hide it, so muted autoplay video still needs controls or a pause button.

Frequently asked questions

Why won't my video autoplay without the muted attribute?
Browsers usually block autoplay for media that would play sound. MDN's autoplay guide notes that the block does not apply once the muted attribute silences the audio, and its example adds playsinline because Safari requires it for autoplay.
How do I unmute a video that has the muted attribute?
Set the video's muted property to false in JavaScript, ideally inside a click handler. The muted attribute stays in the markup because it only describes the starting state.
Does setting muted to false in HTML turn the sound on?
No, any value of the muted attribute still mutes the media. Muted is a boolean attribute, so remove it from the tag to start with sound.
What is the difference between the muted attribute and the muted property?
The muted attribute sets the starting state and is reflected by the defaultMuted property. The muted property reports and changes whether the media is muted right now.
Can viewers turn the sound back on when a video has the muted attribute?
Yes, viewers can unmute from the browser controls when the controls attribute is present. Without controls, add your own button that sets the muted property to false.
Is the muted attribute enough to make autoplay accessible?
The muted attribute satisfies WCAG success criterion 1.4.2 on automatic audio. Motion is separate, so a video that moves for more than five seconds beside other content still needs a pause control under criterion 2.2.2.