<video>


HTML <video> Tag

Instance

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>php中文网(php.cn)</title> 
</head>
<body>

<video width="320" height="240" controls>
  <source src="movie.mp4"  type="video/mp4">
  <source src="movie.ogg"  type="video/ogg">
  您的浏览器不支持 HTML5 video 标签。
</video>

</body>
</html>

Run Example»

Click the "Run Instance" button to view the online instance


Browser support

1000.png

IE 9+, Firefox, Opera, Both Chrome and Safari support the <video> tag.

Note: IE 8 or earlier versions of IE browsers do not support the <video> tag.


Tag definition and usage instructions

<video> tag defines video, such as movie clips or other video streams.

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

BrowserMP4WebMOgg
Internet ExplorerYESNONO
ChromeYESYES YES
FirefoxYES
Starting from Firefox 21 version
Linux system starting from Firefox 30
YESYES
SafariYESNONO
OperaYES
Starting from Opera 25 version
YESYES
  • MP4 = MPEG 4 file using H264 video codec and AAC audio codec
  • WebM = WebM file using VP8 video codec and Vorbis audio codec
  • Ogg = Ogg File uses Theora video codec and Vorbis audio codec

MIME type for audio format

##FormatMIME-typeMP4video/mp4WebMvideo/webmOggvideo/ogg

Differences between HTML 4.01 and HTML5

The<video> tag is a new tag in HTML5.


Tips and Notes

Tips: You can place text content between the <video> and </video> tags, which does not support < The browser of the video> element can display the information of this tag.


Optional attributes

New: New attributes in HTML5.

PropertiesValueDescription
autoplayNew autoplayIf this attribute appears, the video will be played as soon as it is ready.
controlsNewcontrolsIf this attribute appears, displays controls, such as a play button, to the user.
heightNewpixelsSet the height of the video player.
loopNewloopIf this attribute appears, playback will start again after the media file completes playback.
mutedNewmutedIf this attribute appears, the audio output of the video is muted.
posterNewURL#Specifies the image to be displayed while the video is downloading until the user Click the play button.
preloadNewauto
metadata
none
If this attribute appears, the video will be loaded when the page loads and is ready to be played. If "autoplay" is used, this attribute is ignored.
srcNewURLThe URL of the video to play.
widthNewpixelsSet the width of the video player.

Global attributes

The<video> tag supports global attributes of HTML.


Event attributes

<video> tag supports HTML event attributes.