Latest web development tutorials

HTML <video> tag

Examples

Play video:

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

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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

Note: IE 8 or earlier versions of IE browser does not support <video> tag.


Tag definitions and instructions

<Video> tag defines video, such as a movie clip or other video streams.

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

Browser MP4 WebM Ogg
Internet Explorer YES NO NO
Chrome YES YES YES
Firefox YES
Starting from Firefox 21 version
Linux system from Firefox 30 start
YES YES
Safari YES NO NO
Opera YES
Starting from version Opera 25
YES YES
  • MP4 = MPEG 4 files using H264 video codec and AAC audio codec
  • WebM = WebM files using VP8 video codec and Vorbis audio codec
  • Ogg = Ogg files use the Theora video codec and Vorbis audio codec

MIME type of audio format

格式 MIME-type
MP4 video/mp4
WebM video/webm
Ogg video/ogg


Differences between HTML 4.01 and HTML5

<Video> tag HTML5 is the new label.


Tips and Notes

Tip: You can place the text between the <video> and </ video> tag, this is not a supported browser <video> element can display information that tag.


Optional attributes

New: HTML5 new property.

属性 描述
autoplay New autoplay 如果出现该属性,则视频在就绪后马上播放。
controls New controls 如果出现该属性,则向用户显示控件,比如播放按钮。
height New pixels 设置视频播放器的高度。
loop New loop 如果出现该属性,则当媒介文件完成播放后再次开始播放。
muted New muted 如果出现该属性,视频的音频输出为静音。
poster New URL 规定视频正在下载时显示的图像,直到用户点击播放按钮。
preload New auto
metadata
none
如果出现该属性,则视频在页面加载时进行加载,并预备播放。如果使用 "autoplay",则忽略该属性。
src New URL 要播放的视频的 URL。
width New pixels 设置视频播放器的宽度。

Global Properties

<video> tag supports HTML global properties .


Event Properties

<video> tag supports HTML event properties .