Audio and Video tag

Audio and Video tag

In this article, We will know how to embed audio and videos in HTML. You must have seen many web pages there are audio and videos, So let's know what are audio and video tag in HTML and what are their attributes.

let's see what is a video tag -

Video Tag -:

With the help of this tag, you can embed any video on the web page very easily.

Attributes of Video tag -:

  • src - It is used to define the URL of the video.
  • width - Specify the width of the video.
  • height - Specify the height of the video.
  • controls - It gives default controls like play, pause, volume, etc.
  • autoplay - This attribute plays the video automatically.
  • loop - It means whenever the video is finished it will start again.
  • muted - With the help of this attribute, you can mute audio from the video.
  • poster - With this attribute, you can attach an image as a thumbnail.
  • preload - Specifies how the video will be loaded on page load.

Example :

<video controls width="300" height="200" 
        src="/media/cc0-videos/flower.webm"
            type="video/webm">
    </video>

Output -

fgdf.png

Now let's know what is an audio tag -

Audio Tag -:

This tag is exactly the same as the video tag, with this tag you can embed any audio clip or music on the web page very easily.

Attributes of Audio tag -:

The audio tag has the same attributes as the video tag such as controls, src, mute, autoplay, loop, and preload. But some differences in this tag, there is no width, height and poster attribute.

<audio controls src="/media/cc0-audio/t-rex-roar.mp3">
            <a href="/media/cc0-audio/t-rex-roar.mp3">Download audio</a>
      </audio>

Output -

fgdf.png