tadam logo

HTML5 <video> Tag

Example

A video:
<video width="320" height="240" controls="controls">
  <source src="/tryit/video/movie.ogg" type="video/ogg" />
  <source src="/tryit/video/movie.mp4" type="video/mp4" />
  <source src="/tryit/video/movie.webm" type="video/webm" />
  Your browser does not support the video tag.
</video>
The output of the code above will be:

Browser Support

The <video> tag is supported in all major browsers

Definition and Usage

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

Differences Between HTML 4.01 and HTML5

The <video> tag is new in HTML5.

Tips and Notes

Tip: Any text inside the between <video> and </video> will be displayed in browsers that do not support the video element.

Optional Attributes

New : New in HTML5.

AttributeValueDescription
audioNewmutedSpecifies the default state of the the audio. Currently, only "muted" is allowed
autoplayNewautoplayIf present, then the video will start playing as soon as it is ready
controlsNewcontrolsIf present, controls will be displayed, such as a play button
heightNewpixelsSets the height of the video player
loopNewloopIf present, the video will start over again, every time it is finished
posterNewurlSpecifies the URL of an image representing the video
preloadNewauto
metadata
none
Specifies whether or not the video should be loaded when the page loads
srcNewurlThe URL of the video to play
widthNewpixelsSets the width of the video player

Global Attributes

The <video> tag also supports the Global Attributes in HTML5.

Event Attributes

The <video> tag also supports the Event Attributes in HTML5.

Was this information helpful?
   

Comments