The HTML Video element (<video>) embeds a media player which supports video playback into the document. You can use <video> for audio content as well, but the <audio> element may provide a more appropriate user experience.

Content categories Flow content, phrasing content, embedded content. If it has a controls attribute: interactive content and palpable content.
Permitted content

If the element has a src attribute: zero or more <track> elements, followed by transparent content that contains no media elements–that is no <audio> or <video>

Else: zero or more <source> elements, followed by zero or more <track> elements, followed by transparent content that contains no media elements–that is no <audio> or <video>.

Tag omission None, both the starting and ending tag are mandatory.
Permitted parents Any element that accepts embedded content.
Permitted ARIA roles application
DOM interface HTMLVideoElement

Attributes

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

autoPlay
A Boolean attribute; if specified, the video automatically begins to play back as soon as it can do so without stopping to finish loading the data.

Sites which automatically play audio (or videos with an audio track) can be an unpleasant experience for users, so it should be avoided when possible. If you must offer autoplay functionality, you should make it opt-in (requiring a user to specifically enable it). However, this can be useful when creating media elements whose source will be set at a later time, under user control.

To disable video autoplay, autoplay="false" will not work; the video will autoplay if the attribute is there in the <video> tag at all.  To remove autoplay the attribute needs to be removed altogether.

buffered
An attribute you can read to determine the time ranges of the buffered media. This attribute contains a TimeRanges object.
controls
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.
crossorigin
This enumerated attribute indicates whether to use CORS to fetch the related image. CORS-enabled resources can be reused in the <canvas> element without being tainted. The allowed values are:
anonymous
Sends a cross-origin request without a credential. In other words, it sends the Origin: HTTP header without a cookie, X.509 certificate, or performing HTTP Basic authentication. 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
Sends a cross-origin request with a credential. In other words, it sends the Origin: HTTP header with a cookie, a certificate, or performing HTTP Basic authentication. 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.  -- (Absolute values only.  NO percentages)
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: indicates that the video should not be preloaded.
  • metadata: indicates that only video metadata (e.g. length) is fetched.
  • auto: indicates that the whole video file could be downloaded, even if the user is not expected to use it.
  • the empty string: synonym of the auto value.

If not set, its default value is browser-defined (i.e. each browser may have its default value). The spec advises it to be set to metadata.

Usage notes:
  • The autoplay attribute has precedence over preload. If autoplay is specified, the browser would obviously need to start downloading the video for playback.
  • The specification does not force the browser to follow the value of this attribute; it is a mere hint.
poster
A URL for an image to be shown while the video is downloading. If this attribute isn't specified, nothing is displayed until the first frame is available; then the first frame is shown 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.  -- (Absolute values only.  NO percentages)
playsinline
A Boolean attribute which indicates that the video is to be played "inline", that is within the element's playback area. Note that the absence of this attribute does not imply that the video will always be played in fullscreen.

Events

The <video> element can fire many different events.

Usage notes

  • The <video> element contains one or more video sources. To specify a video source, use either the src attribute or the <source> element; the browser will choose the most suitable one. For a list of supported formats, see Media formats supported by the audio and video elements.
  • You can use the object-position property to adjust the positioning of the video within the element's frame, and the object-fit property to control how the video's size is adjusted to fit within the frame.

Examples

<!-- Simple video example -->
<!-- 'Big Buck Bunny' licensed under CC 3.0 by the Blender foundation. Hosted by archive.org -->
<!-- Poster from peach.blender.org -->
<video controls
    src="https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4"
    poster="https://peach.blender.org/wp-content/uploads/title_anouncement.jpg?x11217"
    width="620">

Sorry, your browser doesn't support embedded videos, 
but don't worry, you can <a href="https://archive.org/details/BigBuckBunny_124">download it</a> 
and watch it with your favorite video player!

</video>

This example plays a video when activated, giving the user the browser's default video controls. Until the video starts playing, the image given is displayed in its place. If the browser doesn't support video playback, fallback text is displayed.

Multiple Sources example

<!-- Using multiple sources as fallbacks for a video tag -->
<!-- 'Elephants Dream' by Orange Open Movie Project Studio, licensed under CC-3.0, hosted by archive.org -->
<!-- Poster hosted by Wikimedia -->
<video width="620" controls
  poster="https://upload.wikimedia.org/wikipedia/commons/e/e8/Elephants_Dream_s5_both.jpg" >
  <source
    src="https://archive.org/download/ElephantsDream/ed_1024_512kb.mp4"
    type="video/mp4">
  <source
    src="https://archive.org/download/ElephantsDream/ed_hd.ogv"
    type="video/ogg">
  <source
    src="https://archive.org/download/ElephantsDream/ed_hd.avi"
    type="video/avi">
  Your browser doesn't support HTML5 video tag.
</video>

This example offers three different sources for the media; this allows the video to be watched regardless of which video codecs are supported by the browser; first WebM is tried. If that can't be played, then MP4 is tried. Finally, OGG is tried. A fallback message is displayed if the video tag isn't supported, but not if all sources fail.

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 use Apache Web Server to serve Ogg Theora videos, you can fix this problem by adding the video file type extensions to "video/ogg" MIME type. The most common video file type extensions are ".ogm", ".ogv", or ".ogg". To do this, edit the "mime.types" file in "/etc/apache" or use 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.

Accessibility concerns

Videos should provide both captions and transcripts that accurately describe its content. Captions allow people who are experiencing hearing loss to understand a video's audio content as the video is being played, while transcripts allow people who need additional time to be able to review audio content at a pace and format that is comfortable for them. 

If automatic captioning services are used, it is important to review the generated content to ensure it accurately represents the source video.

In addition to spoken dialog, subtitles and transcripts should also identify music and sound effects that communicate important information. This includes emotion and tone:

14
00:03:14 --> 00:03:18
[Dramatic rock music]

15 
00:03:19 --> 00:03:21
[whispering] What's that off in the distance?

16
00:03:22 --> 00:03:24
It's… it's a…

16 00:03:25 --> 00:03:32
[Loud thumping]
[Dishes clattering]

Captions should not obstruct the main subject of the video. They can be positioned using the align VTT cue setting.

Specifications

Specification Status Comment
HTML Living Standard
The definition of '<video>' in that specification.
Living Standard  

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support3 Yes3.5910.53.1
autoplay3 Yes3.5910.53.1
buffered ? Yes4 ? Yes ?
controls3 Yes3.5910.53.1
crossorigin ? Yes12 ? ? ?
height3 Yes3.5910.53.1
loop3 Yes11910.53.1
muted30 Yes1110 Yes5
played ? Yes15 ? Yes ?
poster3 Yes3.6910.53.1
preload3 Yes49 Yes3.1
src3 Yes3.5910.53.1
width3 Yes3.5910.53.1
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support Yes Yes Yes4 Yes Yes Yes
autoplay Yes Yes Yes4 Yes101 Yes
buffered ? ? Yes4 Yes ? ?
controls Yes Yes Yes4 Yes Yes Yes
crossorigin ? ? Yes14 ? ? ?
height Yes Yes Yes4 Yes Yes Yes
loop Yes Yes Yes14 Yes6 Yes
muted Yes Yes Yes14 Yes ? Yes
played ? ? Yes15 Yes ? ?
poster Yes Yes Yes4 Yes Yes Yes
preload Yes Yes Yes4 Yes Yes Yes
src Yes Yes Yes4 Yes Yes Yes
width Yes Yes Yes4 Yes Yes Yes

1. Only available for videos that have no sound or have the audio track disabled.

See also