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

HTML5 Video (Video)

HTML5 Video (Video)


Many sites use videos. HTML5 provides a standard for displaying videos.

Check whether your browser supports HTML5 video:


Video on Web Sites

Until now, there has been no standard for displaying video on web pages.

Today, most videos are displayed through plugins (such as Flash). However, not all browsers have the same plugins.

HTML5 specifies a standard way to include video through the video element.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Internet Explorer 9+, Firefox, Opera, Chrome, and Safari support

Note: Internet Explorer 8 or earlier IE versions do not support


HTML5 (Video) - How It Works

To display video in HTML5, all you need is:

Example

<

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 »

simultaneously

The content inserted between the tags is displayed for browsers that do not support the video element.


Video Formats and Browser Support

Currently,

Browser MP4 WebM Ogg
Internet Explorer YES NO NO
Chrome YES YES YES
Firefox YES YES YES
Safari YES NO NO
Opera YES (from Opera 25 onwards) YES YES

Video Formats

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

HTML5

HTML5

Its methods are used for playing, pausing, loading, and so on. Its properties (such as duration and volume) can be read or set. Its DOM events can notify you, for example,

The simple methods in the example demonstrate how to use the

Example 1

Create simple play/pause and resize controls for the video:

The example above calls two methods: play() and pause(). It also uses two properties: paused and width.

Try it »

For more reference, see HTML5 Audio/Video DOM Reference Manual。


HTML5 Video Tags

tag Description
Defines a video
Defines multiple media resources, such as
Defines text tracks in a media player