HTML <video> Tag
HTML
The <video> tag is used to embed a media player which supports video playback in an HTML document.
HTML <video> Tag
The <video> tag contains one or more <source> tags with different video sources and a fallback text to inform the user that the browser does not support the <video> element.
The three different video formats mp4, Ogg, and WebM are generally supported by most browsers.
A <video> control can play both video content as well as audio content. But the <audio> player is more suitable for audio content.
Element Attributes
| Attribute | Value | Description |
|---|---|---|
autoplay |
autoplay | Specifies that playback will start automatically as soon as the video is ready. |
controls |
controls | This specifies that video controls should be displayed, such as volume adjusting, retrieval, and playback pause / resume. |
height |
pixels | Specifies height of the video player. |
loop |
loop | Specifies that the browser will automatically return to the beginning after reaching the end of the video. |
muted |
muted | It specifies that the audio output of the video should be muted. |
poster |
url | Specifies an image to be shown while downloading the video. |
preload |
auto metadata none |
This gives the browser a hint that what the author thinks will lead to the best user experience. |
src |
url | It specifies the URL of the video file. |
width |
pixels | It specifies the width of the video player. |
Global attributes
Global attributes may be applied on all elements, although some elements may have no effect on them.
<accesskey>,
<class>,
<contenteditable>,
<contextmenu>,
<data-*>,
<dir>,
<draggable>,
<dropzone>,
<hidden>,
<id>,
<lang>,
<spellcheck>,
<style>,
<tabindex>,
<title>,
<translate>.
Global Event Handler Attributes
Global Event Handler attributes may be applied on all elements, although some elements may have no effect on them.
<onabort>,
<onautocomplete>,
<onautocompleteerror>,
<onblur>,
<oncancel>,
<oncanplay>,
<oncanplaythrough>,
<onchange>,
<onclick>,
<onclose>,
<oncontextmenu>,
<oncuechange>,
<ondblclick>,
<ondrag>,
<ondragend>,
<ondragenter>,
<ondragleave>,
<ondragover>,
<ondragstart>,
<ondrop>,
<ondurationchange>,
<onemptied>,
<onended>,
<onerror>,
<onfocus>,
<oninput>,
<oninvalid>,
<onkeydown>,
<onkeypress>,
<onkeyup>,
<onload>,
<onloadeddata>,
<onloadedmetadata>,
<onloadstart>,
<onmousedown>,
<onmouseenter>,
<onmouseleave>,
<onmousemove>,
<onmouseout>,
<onmouseover>,
<onmouseup>,
<onmousewheel>,
<onpause>,
<onplay>,
<onplaying>,
<onprogress>,
<onratechange>,
<onreset>,
<onresize>,
<onscroll>,
<onseeked>,
<onseeking>,
<onselect>,
<onshow>,
<onsort>,
<onstalled>,
<onsubmit>,
<onsuspend>,
<ontimeupdate>,
<ontoggle>,
<onvolumechange>,
<onwaiting>.
Learning with HTML Editor "Try it Now"
You can edit the HTML code and view the result using online editor.
Example
<video controls>
<source src="videodemo.ogg" type="audio/ogg">
<source src="vediodemo.mp3" type="audio/mpeg">
Sorry this browser does not support the video element.
</video>
Click on the "Try it Now" button to see how it works.