The HTML <video> element is used to embed video content in an HTML document.
It is a container element that can contain one or more <source> elements, each of which specifies a different video file to be played by the browser.
The browser will choose the first file that it is able to play.
The <video> element has several attributes that can be used to control the behavior of the video, including:
src: This attribute specifies the URL of the video file to be played.
autoplay: This attribute, when set to "autoplay", causes the video to start playing as soon as it is loaded.
controls: This attribute, when set to "controls", displays the browser's built-in video controls (such as play/pause, volume, etc.)
loop: This attribute, when set to "loop", causes the video to start again from the beginning when it reaches the end.
preload: This attribute specifies whether the browser should start loading the video as soon as the page loads. The possible values are "none", "metadata", and "auto".
width and height: These attributes specify the dimensions of the video in pixels.
poster: This attribute specifies an image to be displayed before the video starts playing.
Additionally, the <video> element supports a variety of events, such as onplay, onpause, and onended, which can be used to create custom behavior when the video starts, stops or ends.
Examples:
<video src="myvideo.mp4"
controls></video>
<video autoplay loop>
<source src="myvideo.mp4"
type="video/mp4">
<source src="myvideo.webm"
type="video/webm">
Your browser does not support the
video tag.
</video>
In the first example, the video will be embedded in the page and the controls will be displayed. In the second example, the video will play automatically and loop and the browser will choose the first file it can play.
No comments:
Post a Comment