Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML

HTML

Example

Play a video:

<

video

width

=

"

320

"

height

=

"

240

"

controls

<

source

src

=

"

movie.mp4

"

type

=

"

video/mp4

"

<

source

src

=

"

movie.ogg

"

type

=

"

video/ogg

"

Your browser does not support the video tag.

video

Try it »


Browser support

The numbers in the table indicate the first browser version that supports this property.

Element
4.0 9.0 3.5 4.0 10.5

Tag Definition and Usage Notes

Currently,

Browser MP4 WebM Ogg
Internet Explorer YES NO NO
Chrome YES YES YES
Firefox YES
 从 Firefox 21 版本开始       

 Linux 系统从 Firefox 30 开始 | YES | YES |

| Safari | YES | NO | NO | | Opera | YES
Starting from Opera 25 | YES | YES |

Since different browsers support different video formats, it is usually recommended to provide multiple formats:

Example

<

video

controls

width

=

"

640

"

height

=

"

360

"

<

source

src

=

"

movie.mp4

"

type

=

"

video/mp4

"

<

source

src

=

"

movie.webm

"

type

=

"

video/webm

"

Your browser does not support the HTML5 video tag.

video


MIME types for video formats

Format MIME-type
MP4 video/mp4
WebM video/webm
Ogg video/ogg

Differences between HTML 4.01 and HTML5


Tips and Notes

**Tip:** You can place text content between place text content between the tags so that browsers that do not support


Optional Attributes

New: new attribute in HTML5.

property Value Description
autoplayNew autoplay If present, the video will start playing as soon as it is ready.
controlsNew controls If present, controls (such as a play button) will be displayed to the user.
heightNew pixels Sets the height of the video player.
loopNew loop If present, the video will start over again every time it finishes.
mutedNew muted If present, the audio output of the video should be muted.
posterNew URL Specifies an image to display while the video is downloading, until the user clicks the play button.
preloadNew auto
 metadata       

 none | 如果出现该属性,则视频在页面加载时进行加载,并预备播放。如果使用 "autoplay",则忽略该属性。 |

| srcNew | URL | The URL of the video to play. | | widthNew | pixels | Sets the width of the video player. |

Global Attributes


Event attribute