HTML <video>
Tag Tutorial
The <video>
tag in HTML is used to embed a video into a web page. This tag allows you to define a video player on your website, and specify the video file to be played. The <video>
tag also supports various attributes to customize the appearance and behavior of the video player.
How to Use the <video>
Tag
To use the <video>
tag, you need to specify the URL of the video file that you want to embed. Here's an example of how to embed a video file named "example.mp4":
<video src="example.mp4" controls>
Your browser does not support the video tag.
</video>
In this example, the src
attribute specifies the URL of the video file, and the controls
attribute adds a set of playback controls to the video player.
Main Attributes of the <video>
Tag
Attribute | Description |
---|---|
src | Specifies the URL of the video file to be played. |
controls | Adds a set of playback controls to the video player. |
autoplay | Specifies that the video should start playing automatically when the page loads. |
loop | Specifies that the video should start over again when it reaches the end. |
poster | Specifies an image to be shown while the video is downloading, or until the user hits the play button. |
These are just a few of the attributes that can be used with the <video>
tag. For a complete list of attributes and their descriptions, you can refer to the W3Schools website.
Now that you have learned how to use the <video>
tag and its main attributes, you can start embedding videos into your web pages and customize the video player to suit your needs.