English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag大全

HTML: <video> tag

The HTML <video> element is used to embed media players in HTML or XHTML documents, supporting video playback within the document. You can also use the <video> tag for audio content, but the <audio> element may be more suitable for user experience.

Online example

Play video through video:

!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>HTML video tag usage (Basic Tutorial Website oldtoolbag.com)</title>
</head>
<body>
<video controls>
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.webm" type="video/webm">
  <p>Your browser doesn't support HTML5 video. Here is
     a <a href="movie.mp4">link to the video</a> instead.</p>
</video>
</body>
</html>
test to see if </›

browser compatibility

IEFirefoxOperaChromeSafari

All mainstream browsers support.

tag definition and usage instructions

The <video> tag defines a video, such as a movie clip or other video stream.

Currently, the <video> element supports three video formats: MP4and WebM, Ogg.

browserMP4WebMOgg
Internet ExplorerYESNONO
ChromeYESYESYES
FirefoxYES
from Firefox 21 version started
Linux system from Firefox 30 started
YESYES
SafariYESNONO
OperaYES
from Opera 25 version started
YESYES
  • MP4 = MPEG 4files use H264 video codec and AAC audio codec

  • WebM = WebM files use VP8 video codec and Vorbis audio codec

  • Ogg = Ogg files use Theora video codec and Vorbis audio codec

MIME type for audio format

formatMIME-type
MP4video/mp4
WebMvideo/webm
Oggvideo/ogg

HTML 4.01 with HTML5differences

The <video> tag is an HTML5 new tag.

Tips and注意事项

Tip:can be placed between <video> and </The text is placed between the <video> tags, so that browsers that do not support the <video> element can display the information of this tag.

Optional attribute

New : HTML5 new attributes in

AttributeValueDescription
autoplayHTML5autoplayIf this attribute is present, the video will start playing immediately after it is ready.
controlsHTML5controlsIf this attribute is present, controls such as play buttons are displayed to the user.
heightHTML5pixelsSet the height of the video player.
loopHTML5loopIf this attribute is present, the media file will start playing again after it is completed.
mutedHTML5mutedIf this attribute is present, the audio output of the video is muted.
posterHTML5URLSpecify the image to be displayed while the video is downloading, until the user clicks the play button.
preloadHTML5auto
metadata
none
If this attribute is present, the video is loaded and prepared for playback when the page is loaded. If 'autoplay' is used, this attribute is ignored.
srcHTML5URLURL of the video to be played.
widthHTML5pixelsSet the width of the video player.

Global attributes

Support for <video> tag Global attributes of HTML.

Event attributes

Support for <video> tag HTML event attributes.