HTML & CSS Wiki
Advertisement

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:


  • none - Hints that either the author thinks that the user won't need to consult that video or that the server wants to minimize its traffic; in others terms this hint indicates that the video should not be cached.
  • metadata - Hints that though the author thinks that the user won't need to consult that video, fetching the metadata (e.g. length) is reasonable.
  • auto - Hints that the user needs have priority; in others terms this hint indicates that, if needed, the whole video could be downloaded, even if the user is not expected to use it.
  • An empty string - Which is a synonym of the auto value.
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

See Also[]

Advertisement