HTML <video> tag

Updated: 11/13/2018 by Computer Hope

HTML video tagWhen writing in HTML, the <video> tag is an inline element used to embed video content into a web page. It is useful when you want to add 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, as well as related attributes and browser compatibility.

Tip: Using <source> inside of the <video> tag can provide multiple file formats for the same video. The most appropriate one will be selected depending on your browser.

Example of <video> code

<video controls="controls">
Your browser does not support the &lt;video&gt; tag. <source src="../m/computer-hope.mp4" /> </video>

Example result



File formats and browser support

When utilizing the <video> tag, you need to ensure that your sound 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

Within an HTML tag, an attribute dictates certain aspects of an HTML element. Attributes are made up of a name and value pair; all tags support standard attributes. The following table shows all of the current unique HTML attributes for the <video> tag, as well as a description of each.

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 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, Embed, Loop, Mute, Video, Web design terms, Web page