<video>

  • Revision slug: HTML/Element/Video
  • Revision title: video
  • Revision id: 8319
  • Created:
  • Creator: McGurk
  • Is current revision? No
  • Comment Added global attributes text; 13 words added

Revision Content

{{ HTMLVersionHeader("5") }}{{ gecko_minversion_header("1.9.1") }}

The video element is used to embed video content in an HTML or XHTML document.

For a list of supported formats, see Media formats supported by the audio and video elements.

Usage context

Permitted content Transparent content, containing either a src attribute or one or more {{ HTMLElement("source") }} elements, followed by either flow content or phrasing content , with no <video> or {{ HTMLElement("audio") }} elements.
Tag omission None, both start and end tags must be present
Permitted parent elements Any element that accepts flow content, or any element that accepts phrasing content.
Normative document HTML 5, section 4.8.6

Attributes

Like all other HTML elements, this element supports the global attributes.

{{ htmlattrdef("autoplay") }}
A Boolean attribute; if specified, the video will automatically begin to play back as soon as it can do so without stopping to finish loading the data.
{{ htmlattrdef("autobuffer") }} {{ Non-standard_inline() }} {{ obsolete_inline() }}
A Boolean attribute; if specified, the video will automatically begin buffering even if it's not set to automatically play. This should be used for cases in which it is considered likely that the video will be played (for example, if the user navigated to the page specifically to play the video, not if there happens to be a video embedded along with other content). The video is buffered until the media cache is full.
Implementation note: though part of the early drafts of the HTML5 specification, the autobuffer attribute has been removed in later releases. It has been removed from Gecko 2.0 and other browsers, and never implemented in some. The spec defines a new enumerated attribute, preload, to replace the autobuffer attribute, with a different syntax. {{ bug("548523") }}
{{ htmlattrdef("buffered") }} {{ gecko_minversion_inline("2.0") }}
An attribute you can read to determine which time ranges of the media have been buffered. This attribute contains a {{ domxref("TimeRanges") }} object.
{{ htmlattrdef("controls") }}
If this attribute is present, Gecko will offer controls to allow the user to control video playback, including volume, seeking, and pause/resume playback.
{{ htmlattrdef("height") }}
The height of the video's display area, in CSS pixels.
{{ htmlattrdef("loop") }} {{ unimplemented_inline() }} {{ bug("449157") }}
A Boolean attribute; if specified, we will, upon reaching the end of the video, automatically seek back to the start.
{{ htmlattrdef("preload") }} {{ gecko_minversion_inline("2.0") }} {{ bug("548523") }}
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 indicated that, if needed, the whole video could be downloaded, even if the user is not expected to use it.
  • the empty string: which is a synonym of the auto value.

If not set, its default value is browser-defined (i.e. each browser can choose its own default value), though the spec advises it to be set to metadata.

Usage notes:
  • The autoplay attribute has precedence over this one as if one wants to automatically play a video, the browser will obviously need to download it. Setting both the autoplay and the preload attributes is allowed by the specification.
  • The browser is not forced by the specification to follow the value of this attribute; it is a mere hint.
{{ htmlattrdef("poster") }} {{ gecko_minversion_inline("1.9.2") }}
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.
{{ htmlattrdef("src") }}
The URL of the video to embed. This is optional; you may instead use the {{ HTMLElement("source") }} element within the video block to specify the video to embed.
{{ htmlattrdef("width") }}
The width of the video's display area, in CSS pixels.

Time offsets are currently specified as a float value representing the number of seconds to offset.

Note: The time offset value definition has not yet been completed in the HTML 5 specification and is subject to change.

Examples

<video src="videofile.ogg" autoplay poster="posterimage.jpg">
  Your browser does not support the <code>video</code> element.
</video>

Plays a video, starting playback as soon as enough of the video has been received to allow playback without pausing to download more. Until the video starts playing, the image "posterimage.jpg" is displayed in its place.

Server support

It's worth re-emphasizing for the time being, that if the MIME types for Theora video are not set on the server, the video may not show or show a gray box containing an X (if JavaScript is enabled).

You can fix this problem for the Apache Web Server by adding the extension used by your Theora video files (".ogm", ".ogv", or ".ogg" are the most common ones) to the MIME type "video/ogg" via the "mime.types" file in "/etc/apache" or  via the "AddType" configuration directive in httpd.conf.

AddType video/ogg .ogm
AddType video/ogg .ogv
AddType video/ogg .ogg

Your web host may provide an easy interface to MIME type configuration changes for new technologies until a global update naturally occurs.

DOM Interface

See also

{{ languages( { "fr": "fr/HTML/Element/video","es": "es/HTML/Elemento/video" } ) }}

Revision Source

<p>{{ HTMLVersionHeader("5") }}{{ gecko_minversion_header("1.9.1") }}</p>
<p>The <code>video</code> element is used to embed video content in an HTML or XHTML document.</p>
<p>For a list of supported formats, see <a href="/En/Media_formats_supported_by_the_audio_and_video_elements" title="En/Media formats supported by the audio and video elements">Media formats supported by the audio and video elements</a>.</p>
<h2>Usage context</h2>
<table class="standard-table"> <tbody> <tr> <td>Permitted content</td> <td><a href="/en/HTML/Content_categories#transparent_content" title="en/HTML/Content categories#transparent content">Transparent content</a>, containing either a <strong>src</strong> attribute or one or more {{ HTMLElement("source") }} elements, followed by either <a href="/en/HTML/Content_categories#flow_content" title="en/HTML/Content categories#flow content">flow content</a> or <a href="/en/HTML/Content_categories#phrasing_content" title="en/HTML/Content categories#phrasing content">phrasing content</a> , with no <code>&lt;video&gt;</code> or {{ HTMLElement("audio") }} elements.</td> </tr> <tr> <td>Tag omission</td> <td>None, both start and end tags must be present</td> </tr> <tr> <td>Permitted parent elements</td> <td>Any element that accepts <a href="/en/HTML/Content_categories#flow_content" title="en/HTML/Content categories#flow content">flow content</a>, or any element that accepts <a href="/en/HTML/Content_categories#phrasing_content" title="en/HTML/Content categories#phrasing content">phrasing content</a>.</td> </tr> <tr> <td>Normative document</td> <td><a class=" external" href="http://www.w3.org/TR/html5/video.html#video" title="http://www.w3.org/TR/html5/video.html#video">HTML 5, section 4.8.6</a></td> </tr> </tbody>
</table>
<h2>Attributes</h2>
<p>Like all other HTML elements, this element supports the <a href="/en/HTML/Global_attributes" title="en/HTML/Global attributes">global attributes</a>.</p>
<dl> <dt>{{ htmlattrdef("autoplay") }}</dt> <dd>A Boolean attribute; if specified, the video will automatically begin to play back as soon as it can do so without stopping to finish loading the data.</dd> <dt>{{ htmlattrdef("autobuffer") }} {{ Non-standard_inline() }} {{ obsolete_inline() }}</dt> <dd>A Boolean attribute; if specified, the video will automatically begin buffering even if it's not set to automatically play. This should be used for cases in which it is considered likely that the video will be played (for example, if the user navigated to the page specifically to play the video, not if there happens to be a video embedded along with other content). The video is buffered until the media cache is full. <div class="note"><strong>Implementation note:</strong> though part of the early drafts of the HTML5 specification, the <strong>autobuffer</strong> attribute has been removed in later releases. It has been removed from Gecko 2.0 and other browsers, and never implemented in some. The spec defines a new enumerated attribute, <strong>preload</strong>, to replace the <strong>autobuffer</strong> attribute, with a different syntax. {{ bug("548523") }}</div> </dd> <dt>{{ htmlattrdef("buffered") }} {{ gecko_minversion_inline("2.0") }}</dt> <dd>An attribute you can read to determine which time ranges of the media have been buffered. This attribute contains a {{ domxref("TimeRanges") }} object.</dd> <dt>{{ htmlattrdef("controls") }}</dt> <dd>If this attribute is present, Gecko will offer controls to allow the user to control video playback, including volume, seeking, and pause/resume playback.</dd> <dt>{{ htmlattrdef("height") }}</dt> <dd>The height of the video's display area, in CSS pixels.</dd> <dt>{{ htmlattrdef("loop") }} {{ unimplemented_inline() }} {{ bug("449157") }}</dt> <dd>A Boolean attribute; if specified, we will, upon reaching the end of the video, automatically seek back to the start.</dd> <dt>{{ htmlattrdef("preload") }} {{ gecko_minversion_inline("2.0") }} {{ bug("548523") }}</dt> <dd>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: <ul> <li><span style="font-family: Courier New;">none: </span>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.</li> <li><span style="font-family: Courier New;">metadata</span>: hints that though the author thinks that the user won't need to consult that video, fetching the metadata (e.g. length) is reasonable.</li> <li><span style="font-family: Courier New;">auto</span>: hints that the user needs have priority; in others terms this hint indicated that, if needed, the whole video could be downloaded, even if the user is not expected to use it.</li> <li>the <em>empty string</em>: which is a synonym of the <span style="font-family: Courier New;">auto </span>value.</li> </ul> <p>If not set, its default value is browser-defined (i.e. each browser can choose its own default value), though the spec advises it to be set to <span style="font-family: Courier New;">metadata</span>.</p> <div class="note"><strong>Usage notes:</strong> <ul> <li>The <strong>autoplay </strong>attribute has precedence over this one as if one wants to automatically play a video, the browser will obviously need to download it. Setting both the <strong>autoplay</strong> and the <strong>preload</strong> attributes is allowed by the specification.</li> <li>The browser is not forced by the specification to follow the value of this attribute; it is a mere hint.</li> </ul> </div> </dd> <dt>{{ htmlattrdef("poster") }} {{ gecko_minversion_inline("1.9.2") }}</dt> <dd>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.</dd> <dt>{{ htmlattrdef("src") }}</dt> <dd>The URL of the video to embed. This is optional; you may instead use the {{ HTMLElement("source") }} element within the video block to specify the video to embed.</dd> <dt>{{ htmlattrdef("width") }}</dt> <dd>The width of the video's display area, in CSS pixels.</dd>
</dl>
<p>Time offsets are currently specified as a float value representing the number of seconds to offset.</p>
<div class="note"><strong>Note:</strong> The time offset value definition has not yet been completed in the HTML 5 specification and is subject to change.</div><h2>Examples</h2>
<pre class="brush: html">&lt;video src="videofile.ogg" autoplay poster="posterimage.jpg"&gt;
  Your browser does not support the &lt;code&gt;video&lt;/code&gt; element.
&lt;/video&gt;
</pre>
<p>Plays a video, starting playback as soon as enough of the video has been received to allow playback without pausing to download more. Until the video starts playing, the image "posterimage.jpg" is displayed in its place.</p>
<h2>Server support</h2>
<p>It's worth re-emphasizing for the time being, that if the MIME types for Theora video are not set on the server, the video may not show or show a gray box containing an X (if JavaScript is enabled).</p>
<p>You can fix this problem for the Apache Web Server by adding the extension used by your Theora video files (".ogm", ".ogv", or ".ogg" are the most common ones) to the MIME type "video/ogg" via the "mime.types" file in "/etc/apache" or  via the "AddType" configuration directive in httpd.conf.</p>
<pre>AddType video/ogg .ogm
AddType video/ogg .ogv
AddType video/ogg .ogg
</pre>
<p>Your web host may provide an easy interface to MIME type configuration changes for new technologies until a global update naturally occurs.</p>
<h2>DOM Interface</h2>
<ul> <li><a href="/en/DOM/HTMLVideoElement" title="en/DOM/HTMLVideoElementInterface">HTMLVideoElement</a></li>
</ul>
<h2>See also</h2>
<ul> <li><a class="internal" href="/En/Media_formats_supported_by_the_audio_and_video_elements" title="En/Media formats supported by the audio and video elements">Media formats supported by the audio and video elements</a></li> <li><a class="internal" href="/En/HTML/Element/Audio" title="En/HTML/Element/Audio"><code>audio</code></a></li> <li><a class="internal" href="/En/Using_audio_and_video_in_Firefox" title="En/Using audio and video in Firefox">Using audio and video in Firefox</a></li> <li><a class="internal" href="/En/Manipulating_video_using_canvas" title="En/Manipulating video using canvas">Manipulating video using canvas</a></li> <li><a class="internal" href="/En/XPCOM_Interface_Reference/NsIDOMHTMLMediaElement" title="En/NsIDOMHTMLMediaElement"><code>nsIDOMHTMLMediaElement</code></a></li> <li><a class="external" href="http://tinyvid.tv/" title="http://tinyvid.tv/">TinyVid</a> - examples using ogg files in HTML 5.</li> <li><a class="external" href="http://www.whatwg.org/specs/web-apps/current-work/#video" title="http://www.whatwg.org/specs/web-apps/current-work/#video">The <code>video</code> element</a> (HTML 5 specification)</li> <li><a class="internal" href="/en/Configuring_servers_for_Ogg_media" title="en/Configuring servers for Ogg media">Configuring servers for Ogg media</a></li>
</ul>
<p>{{ languages( { "fr": "fr/HTML/Element/video","es": "es/HTML/Elemento/video" } ) }}</p>
Revert to this revision