ClickStart logoHTML5 to the point

Inserting video into a document

You can use the video element to insert a video file into a document. You can even use the source element to specify multiple formats for different browsers.

The video element includes the following attributes:

Attribute

Description

autoplay

Starts loading the video immediately on page load and plays it when it is loaded.

controls

Adds playback controls.

height

Sets the video's height.

loop

Replays the video when it is finished playing.

preload

Starts loading the video immediately on page load, but does not play the video.

src

Specifies the URL of the video file.

width

Sets the video's width.

If you only specify the width or height, the video will be sized to preserve its aspect ratio. If you specify a width and height that does not match the video's aspect ratio, the video will be letter-boxed using its original aspect ratio.

Screenshot

Code

<video src="klose.ogg" type="video/ogg" controls></audio>

or

<video controls>
<source src="klose.ogg" type="video/ogg">
<source src="klose.mp4" type="video/mp4">
<object data="klose.swf" type="application/x-shockwave-flash"> <param value="klose.swf" name="movie" /> </object>
</video>

Example