HTML <video> Tag

<video> tag is used to embed video content in a web page. It allows you to include video files and provides controls for playing, pausing, and adjusting the volume of the video.

Basic Syntax of <video> tag:

<video src="video.mp4"controls>
    Your browser does not support the video tag.
</video>

Attributes of Video tag:

  • src: Specifies the path to the video file. If this attribute is not used, you must include one or more <source> elements inside the <video> tag.
  • controls: Adds video controls like play, pause, and volume. This attribute is a boolean attribute, meaning if present, the controls are enabled.
  • autoplay: Automatically starts playing the video when the page loads. If used without a value, it will autoplay the video.
  • loop: Makes the video start over again automatically after it finishes playing.
  • muted: Mutes the video by default
  • width and height: Define the width and height of the video player.
  • poster Specifies an image to be shown while the video is loading. It is useful to provide a preview of the video.

Multiple Sources:

Example Of Multiple sources of Video:

<video src="video.mp4" width="640" height="360" controls autoplay loop poster="preivew.jpg">
    <source src="movie.mp4" type="video/mp4">
    <source src="movie.webm" type="video/webm">
    <source src="movie.ogv" type="video/ogg">
    Your browser does not support the video tag.
</video>

HTML <audio> Tag

<audio> tag is used to embed sound content in a web page. It allows you to include audio files and provides controls for playing, pausing, and adjusting the volume of the audio.

Basic Syntax of <audio> tag:
<audio src="audio.mp3"controls>
    Your browser does not support the audio tag.
</audio>

Attributes Audio tag:

  • src:Specifies the path to the audio file. If this attribute is not used, you must include one or more <source> elements inside the <audio> tag.
  • controls: Adds audio controls like play, pause, and volume. This attribute is a boolean attribute, meaning if present, the controls are enabled.
  • autoplay: Automatically starts playing the audio when the page loads. If used without a value, it will autoplay the audio.
  • loop: Makes the audio start over again automatically after it finishes playing.
  • muted: Mutes the audio by default.
  • preload Specifies how the audio should be loaded when the page loads. Possible values are:
    • auto: The browser should load the audio when the page loads.
    • none: The browser should not preload the audio.

Multiple Sources:

Example Of Multiple sources of Audio:

<audio src="audio.mp3" controls autoplay loop">
    <source src="song.mp3" type="audio/mpeg">
    <source src="song.ogg" type="audio/ogg">
    <source src="song.wav" type="audio/wav">
    Your browser does not support the audio element.
</audio>