Audio and Video Tag

·

2 min read

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="/Container/pexels-dario-fernandez-ruz-9130080.mp4">
    </video>

Output -

Screenshot 2022-12-01 215750.jpg

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.

Example :

<audio controls 
src="/Container/mixkit-retro-game-emergency-alarm-1000.wav">
</audio>

Output -

Screenshot 2022-12-01 215830.jpg