The HTML <video></video>
element was first introduced in HTML5. It is used to embed video content in an HTML or XHTML document. Currently only .ogg
, .mp4
, and .webm
video files are supported.
Attributes[]
Attribute | Value | Description |
---|---|---|
autoplay |
Boolean | If specified, the video will automatically begin to play back as soon as it can do so without stopping to finish loading the data. |
autobuffer |
Boolean | Obsolete, non-standard |
buffered |
TimeRanges object | An attribute you can read to determine which time ranges of the media have been buffered. |
controls |
Please Provide | If this attribute is present, the browser will offer controls to allow the user to control video playback, including volume, seeking, and pause/resume playback. |
height |
number | The height of the video's display area, in CSS pixels. |
loop |
Boolean | If specified, upon reaching the end of the video, it automatically seek back to the start. (Unimplemented in Gecko) |
preload |
Read descrip → | This enumerated attribute is intended to provide a hint to the browser about what the author thinks will lead to the best user experience. It may have one of the following values:
|
poster |
URL | A URL indicating a poster frame to show until the user plays or seeks. If this attribute isn't specified, nothing is displayed until the first frame is available; then the first frame is displayed as the poster frame. |
src |
URL | The URL of the video to embed. This is optional; you may instead use the <source> element within the video block to specify the video to embed.
|
width |
number | The width of the video's display area, in CSS pixels. |
HTML example 1:
<video src="video.ogg" autoplay poster="posterimage.jpg">
Your browser does not support the <code><video></code> element.
</video>
HTML example 2:
<video height="200" width="200" controls>
<source src="whatever.ogg" type="video/ogg" />
<source src="whatever.mp4" type="video/mp4" />
</video>
Below is an example of a video from YouTube. Although it is not rendered using this element, it is pretty similar.
left|250px