HTML <video>Tag


Examples

Play the 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 Yourself »

Browser Support

The numbers in the table specify the first browser version that fully supports this attribute.

Element
<video> 4.0 9.0 3.5 4.0 10.5

Definition and Usage

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

Currently, the <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 with Firefox 21
Linux systems starting with Firefox 30
YES YES
Safari YES NO NO
Opera YES
Starting with Opera 25
YES YES
  • MP4 = MPEG 4 files with H264 video codec and AAC audio codec
  • WebM = WebM files with VP8 video codec and Vorbis audio codec
  • Ogg = Ogg files with Theora video codec and Vorbis audio codec

Because 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

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


Tips and Notes

Tip:You can place text content between the <video> and </video> tags, so that browsers that do not support the <video> element can display the information in the tag.


Optional Attributes

New: New attribute in HTML5.

Attribute Value Description
autoplayNew autoplay If this attribute is present, the video will play as soon as it is ready.
controlsNew controls If this attribute is present, controls are displayed to the user, such as a play button.
heightNew pixels Sets the height of the video player.
loopNew loop If this attribute is present, the media file will start over again after it finishes playing.
mutedNew muted If this attribute is present, the video's audio output is muted.
posterNew URL Specifies an image to be shown while the video is downloading, until the user clicks the play button.
preloadNew auto
metadata
none
If this attribute is present, the video is loaded when the page loads and is prepared to play. If "autoplay" is used, this attribute is ignored.
srcNew URL The URL of the video to play.
widthNew pixels Sets the width of the video player.

Global Attributes

The <video> tag supportsHTML global attributes.。


Event Attributes

The <video> tag supportsHTML event attributes.。

Other Extensions