Your Search Results

    <video> Redirect 1

    Introduced in HTML5

    Summary

    The HTML <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 HTML5, 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.
    autobuffer
    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
    buffered
    An attribute you can read to determine which time ranges of the media have been buffered. This attribute contains a TimeRanges object.
    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.
    crossorigin
    This enumerated attribute indicates if the fetching of the related image must be done using CORS or not. CORS-enabled resources can be reused in the <canvas> element without being tainted. The allowed values are:
    anonymous
    A cross-origin request (i.e. with Origin: HTTP header) is performed. But no credential is sent (i.e. no cookie, no X.509 certificate and no HTTP Basic authentication is sent). If the server does not give credentials to the origin site (by not setting the Access-Control-Allow-Origin: HTTP header), the image will be tainted and its usage restricted..
    use-credentials
    A cross-origin request (i.e. with Origin: HTTP header) is performed with credential is sent (i.e. a cookie, a certificate and HTTP Basic authentication is performed). If the server does not give credentials to the origin site (through Access-Control-Allow-Credentials: HTTP header), the image will be tainted and its usage restricted.
    When not present, the resource is fetched without a CORS request (i.e. without sending the Origin: HTTP header), preventing its non-tainted used in <canvas> elements. If invalid, it is handled as if the enumerated keyword anonymous was used. See CORS settings attributes for additional information.
    height
    The height of the video's display area, in CSS pixels.
    loop
    A Boolean attribute; if specified, we will, upon reaching the end of the video, automatically seek back to the start.
    muted
    A Boolean attribute which indicates the default setting of the audio contained in the video. If set, the audio will be initially silenced. Its default value is false, meaning that the audio will be played when the video is played.
    played
    A TimeRanges object indicating all the ranges of the video that have been played.
    preload
    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.
    poster
    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.

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

    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

    If the MIME type for the video is not set correctly on the server, the video may not show or show a gray box containing an X (if JavaScript is enabled).

    If you serve your videos as Ogg Theora, you can fix this problem for the Apache Web Server by adding the extension used by your 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
    

    If you serve your videos as WebM you can fix this problem for the Apache Web Server by adding the extension used by your video files (".webm" is the most common one) to the MIME type "video/webm" via the "mime.types" file in "/etc/apache" or via the "AddType" configuration directive in httpd.conf.

    AddType video/webm .webm
    

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

    DOM interface

    This element implements the HTMLVideoElement interface.

    Browser compatibility

    Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
    Basic support 3.0 3.5 (1.9.1) 9.0 10.5 3.1
    autoplay attribute 3.0 3.5 (1.9.1) 9.0 10.5 3.1
    buffered attribute ? 4.0 (2.0) ? Yes ?
    controls attribute 3.0 3.5 (1.9.1) 9.0 10.5 3.1
    loop attribute 3.0 11.0 (11.0) 9.0 10.5 3.1
    muted attribute ? 11.0 (11.0) ? Yes ?
    played property ? 15.0 (15.0) ? Yes ?
    poster attribute 3.0 3.6 (1.9.2) 9.0 10.5 3.1
    preload attribute 3.0 4.0 (2.0) 9.0 Yes 3.1
    src attribute 3.0 3.5 (1.9.1) 9.0 10.5 3.1
    crossorigin attribue ? 12.0 (12.0) ? ? ?
    Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
    Basic support ? 1.0 (1.0) ? ? ?
    autoplay attribute ? 1.0 (1.0) ? ? iOS 6.0 only
    buffered attribute ? 4.0 (2.0) ? ? ?
    controls attribute ? 1.0 (1.0) ? ? ?
    loop attribute ? 11.0 (11.0) ? ? ?
    muted attribute ? 11.0 (11.0) ? ? ?
    played property ? 15.0 (15.0) ? ? ?
    poster attribute ? 1.0 (1.0) ? ? ?
    preload attribute ? 4.0 (2.0) ? ? ?
    src attribute ? 1.0 (1.0) ? ? ?
    crossorigin attribute ? 12.0 (12.0) ? ? ?

    See also

    Document Tags and Contributors

    Contributors to this page: Sheppy
    Last updated by: Sheppy,