How to mute video in HTML?
< video > tag
HTML 5 contains a special < video > tag to easily embed a media player inside the web page, which helps us support video playback inside the web page document. Apart from the video, we can also play music and audio. Still, for that, < audio > tag is a better option also present there in HTML 5.
The < video > tag contains multiple attributes which can be used to perform multiple operations
- Auto play – next video automatically begins after one
- control – the browser will provide to control video
- loop – automatically start the same video once this end
- height – adjust the height
- width – adjust the width
There are two different ways to mute a video in HTML
Step1) By using the mute attribute present inside the video tag in HTML5
Muted attribute of < video > tag
Along with the attributes mentioned above, < video > tag also contains a Boolean attribute known as muted which is an attribute that specifies the embedded media player that the audio output of the video must be muted
< video controls muted >
Program to display the use of mute attribute
Here in this program, we have used the default video element of HTML 5 assigned with a source code of our video and used a muted attribute, which will add a small mute icon below the video screen with other control options. We can easily use the mute icon to switch between mute and unmute options.
Step 2) By using the video DOM muted property
Video . muted = true