Summary -
In this topic, we described about the <video> tag along with detailed example.
The <video> element was introduced in HTML 5. Defines video or movie streams in the HTML document. <video> tag is commonly used to embed video files to web pages.
MP3, Wav and Ogg are the 3 supported file formats for the <vide> element. MP3 format is supported by all browsers.
The URL of the video file can be specified in between the opening and closing tags <video src="" controls></video>.
Any content in between the opening and closing <video> tags is replacement content if browser not supported the <video> tag or <video> format.
Syntax -
<video>….</video>
Optional Attributes -
Attribute | Description | Values |
---|---|---|
autoplay | Specifies the video can be loading and playing will be done automatically. | None. |
controls | Instructs the web browser to apply browsers in-built set of user controls (to stop, play, mute, etc.). | None. |
crossorigin | Used to handle Cross Origin Resource Sharing requests in conjunction with JavaScript | |
loop | Specifies that replay the video once it has finished. | None. |
mediagroup | Used to group several audio and/or video elements together. | Text. |
muted | Specifies that mute the video resource by default. | None. |
preload | Specifies the size of the video file should be buffered. | none: specifies fetch video data once playback has been appealed.
metadata: Fetch the duration data. auto: User specification comes before server |
src | Specifies the location of the video file. | URL. |
Example -
<!DOCTYPE html>
<html>
<head>
<title>Track tag example.. </title>
</head>
<body>
<video width="360" height="240" controls>
<source src="video/light.mp4" type="video/mp4">
</video>
</body>
</html>