<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
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.
Browser | MP4 | WebM | Ogg |
---|---|---|---|
Internet Explorer | YES | NO | NO |
Chrome | YES | YES | YES |
Firefox | YES Starting from Firefox 21 version Linux system starting from Firefox 30 | YES | YES |
Safari | YES | NO | NO |
Opera | YES Starting from Opera 25 version | YES | YES |
- 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
MIME-type | ||
---|---|---|
video/mp4 | ||
video/webm | ||
video/ogg |
Properties | Value | Description |
---|---|---|
autoplayNew | autoplay | If this attribute appears, the video will be played as soon as it is ready. |
controlsNew | controls | If this attribute appears, displays controls, such as a play button, to the user. |
heightNew | pixels | Set the height of the video player. |
loopNew | loop | If this attribute appears, playback will start again after the media file completes playback. |
mutedNew | muted | If this attribute appears, the audio output of the video is muted. |
posterNew | URL | #Specifies the image to be displayed while the video is downloading until the user Click the play button. |
preloadNew | auto 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. |
srcNew | URL | The URL of the video to play. |
widthNew | pixels | Set the width of the video player. |
Global attributes
The<video> tag supports global attributes of HTML.
Event attributes
<video> tag supports HTML event attributes.