HTML <video> tag
When writing in HTML (hypertext markup language), the <video> tag is an inline element used to embed video content into a web page. It is useful for adding any video, such as a music video or news report, to your web pages. The following sections contain information about this tag, including an example of it in use, and related attributes and browser compatibility.
Using <source> in the <video> tag can provide multiple file formats for the same video. The most appropriate one is selected depending on your browser.
Example of <video> code
<video controls="controls">
Your browser does not support the <video> tag. <source src="../m/computer-hope.mp4" /> </video>
Example result
File formats and browser support
When utilizing the <video> tag, ensure the file is in the proper format. There are three accepted formats which include MP4, Ogg, and WebM. The table below shows which Internet browsers support which file format.
Browser | MP4 | Ogg | WebM |
---|---|---|---|
Chrome | Yes | Yes | Yes |
Internet Explorer | Yes | No | No |
Firefox | Yes | Yes | Yes |
Safari | Yes | No | No |
Opera | Yes | Yes | Yes |
Attributes
All HTML tags support standard attributes that define the settings of an HTML element. In addition to the standard settings, the <video> tag has the following unique attributes.
Attribute | Description |
---|---|
autoplay | Designates that the video will play immediately after it loads. |
controls | Designates what controls to display with the video player. |
height | Designates the height of the video player. |
loop | Designates that the video should continuously repeat. |
muted | Designates that the audio output should be muted. |
poster | Designates an image to be shown while the video is downloading, or first loads. |
preload | Designates how and when the video should load. |
src | Designates the URL (uniform resource locator) of the video. |
width | Designates the width of the video player. |
Compatibility
Edge | Internet Explorer | Firefox | Safari | Opera | Chrome |
---|---|---|---|---|---|
All versions | 9.0+ | 3.5+ | 4.0+ | 10.5+ | 3.0+ |
Browser, Code, Compatibility, Container tag, Embed, Loop, Mute, Video, Web design terms, Web page