Language References
Embeds video content in an HTML document. | HTML 5 |
HTML Syntax
<video
autoplay
controls
height = n
loop
muted
poster = url
preload = auto | metadata | none
src = url
width = n
event = script
>
The VIDEO element is used to embed video content in an HTML document, without requiring any third-party plug-in or involve complex scripting.
In its simplest form, the src attribute is required, which specifies the location of the video file to embed.
Alternatively, authors can use the SOURCE element, as it allows for multiple alternative options.
A <source
> tag specifies a video file, which can be any of three supported video formats in HTML: MP4, WebM, and OGG.
The <source
> tags are defined as child elements of the <video
>...</video
> tag.
<video ...>
<source src="clip.mp4" ...>
<source src="clip.ogg" ...>
</video>
The browser plays the first source it supports.
In addition, a VIDEO element can contain one or more TRACK elements when the video content includes tracks for captions, chapters, descriptions, metadata or subtitles.
Likewise, <track
> tags are defined as child elements of the <video
>...</video
> tag.
<video ...>
<source src="clip.mp4" ...>
<source src="clip.ogg" ...>
<track src="subs_en.vtt" kind="subtitles" ...>
<track src="subs_no.vtt" kind="subtitles" ...>
</video>
A download link or some “fallback” text can be defined within the <video
>...</video
> tags, to provide alternate content in cases where the browser does not support the VIDEO element or the video content, or somehow failed to download the video source file.
<video src="clip.mp4" ...>
Sorry, your browser does not support video playback.
http://somewhere.com/media/clip.mp4
</video>
NOTE: Both start and end tags are required.
The <video
> element supports the following attributes, in addition to global attributes common to all HTML media elements.
Attribute | Value | Description |
autoplay | autoplay | Specifies whether the video will automatically start playing as soon as it can do so. |
controls | controls | Specifies whether to display video controls that allow users to play/stop video, adjust/mute volume, etc. |
height | pixels | Sets the height of the video’s display area. |
loop | loop | Specifies whether the video will automatically start over again, upon reaching the end. |
muted | muted | Specifies whether the audio ouput is silenced. |
poster | URL | Specifies an image to be shown while the video is loading, or until the user hits the play button. |
preload | auto | metadata | none | Specifies if and how the author thinks the video should be loaded when the page loads. Setting autoplay overrides this attribute. |
src | URL | Required. Specifies the location of the video file to embed. |
width | pixels | Sets the width of the video’s display area. |
<video autoplay controls width=640 height=360>
<source src="praise.mp4" type="video/mp4">
Sorry, your browser does not support the video element.
</video>
which would render on a Web page as follows:
AUDIO EMBED OBJECT