Table of contents
- 1. Usage context
- 2. Attributes
- 3. Examples
- 4. Server support
- 5. DOM Interface
- 6. See also
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
<source> elements, followed by either flow content or phrasing content , with no <video> or
<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.
-
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.
-
autobufferNon-standard Obsolete - 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
-
bufferedRequires Gecko 2.0 - An attribute you can read to determine which time ranges of the media have been buffered. This attribute contains a
TimeRangesobject. -
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.
-
height - The height of the video's display area, in CSS pixels.
-
loopUnimplemented bug 449157 - A Boolean attribute; if specified, we will, upon reaching the end of the video, automatically seek back to the start.
-
preloadRequires Gecko 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.
-
posterRequires Gecko 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.
-
src - 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 - 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.
Examples
<!-- Simple video example --> <video src="videofile.ogg" autoplay poster="posterimage.jpg"> Sorry, your browser doesn't support embedded videos, but don't worry, you can <a href="videofile.ogg">download it</a> and watch it with your favorite video player! </video> <!-- Video with subtitles --> <video src="foo.ogg"> <track kind="subtitles" src="foo.en.vtt" srclang="en" label="English"> <track kind="subtitles" src="foo.sv.vtt" srclang="sv" label="Svenska"> </video>
The first example 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.
The second example allows the user to choose between different subtitles.
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
- Media formats supported by the audio and video elements
audio- Using audio and video in Firefox
- Manipulating video using canvas
nsIDOMHTMLMediaElement- TinyVid - examples using ogg files in HTML 5.
- The
videoelement (HTML 5 specification) - Configuring servers for Ogg media

