HTML <video> tag
Definition and usage
<video>
tag used to embed video content in a document, such as a movie clip or other video stream.
<video>
tag containing one or more sources with different video sources <source> tag. The browser will choose the first source it supports.
<video>
and </video>
The text between the tags will only be displayed in browsers that do not support <video>
displayed in the browser of the element.
HTML supports three video formats: MP4, WebM, and OGG.
Browser | MP4 | WebM | Ogg |
---|---|---|---|
Edge | Supported | Supported | Supported |
Chrome | Supported | Supported | Supported |
Firefox | Supported | Supported | Supported |
Safari | Supported | Supported | Not supported |
Opera | Supported | Supported | Supported |
See also:
HTML DOM Reference Manual:HTML Audio/Video DOM Reference Manual
Example
Play video:
<video width="640" height="360" controls> <source src="shanghai.mp4" type="video/mp4"> <source src="shanghai.ogg" type="video/ogg"> Your browser does not support the video tag. </video>
Tips and comments
Tip:For audio files, see the <audio> tag.
Optional attribute
Attribute | Value | Description |
---|---|---|
autoplay | autoplay | Specify that the video should start playing immediately after it is ready. |
controls | controls | Specify the video controls that should be displayed (such as play/pause buttons, etc.). |
height | Pixels | Set the height of the video player. |
loop | loop | Specify that the video should restart at the end every time. |
muted | muted | Specify that the audio output of the video should be muted. |
poster | URL | Specify the image to be displayed while downloading the video or before the user clicks the play button. |
preload |
|
Specify whether the video should be loaded or how it should be loaded when the page is loaded. |
src | URL | Specify the URL of the video file. |
width | Pixels | Set the width of the video player. |
Global Attributes
<video>
The tag also supports Global Attributes in HTML.
Event Attributes
<video>
The tag also supports Event Attributes in HTML.
Default CSS Settings
None.
Browser Support
The numbers in the table indicate the first browser version to fully support this attribute.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
4.0 | 9.0 | 3.5 | 3.1 | 11.5 |