Code has been added to clipboard!

HTML video Tag

Reading time 2 min
Published Feb 27, 2019
Updated Oct 1, 2019

HTML video Tag: Main Tips

  • By using the <video> tag, you can make HTML insert video to your page.
  • This tag was introduced in HTML5.
  • It supports global attributes.

Using the video Tag

The HTML video tag includes a video on the web page. It works in a similar manner as the <object> tag.

Example
<video controls width="400" height="300">
  <source src="video-tag-example.mp4" type="video/mp4">
  <source src="video-tag-sample.webm" type="video/webm">
  <source src="video-tag-demo.ogg" type="video/ogg">
  Video tag is not supported in this browser.
</video>

This tag is compatible with MP4, WebM, and Ogg file types. To avoid video codecs and browser compatibility issues, it's best that you add multiple sources to the video.

It is mandatory to use both opening and closing video HTML tags. If the browser cannot show the video, it will display the text you write between them.

Mostly Used video Tag Attributes

autoplay specifies whether the video should play automatically when it's ready:

Example
<video controls autoplay width="400" height="300">
  <source src="video-tag-example.mp4" type="video/mp4">
  Video tag is not supported in this browser.
</video>

Note: to stop the video from auto-playing, remove the attribute altogether. Simply changing its value to false won't help.

controls specifies whether the video should have player control buttons (play, pause, volume, etc.):

Example
<video controls width="400" height="300">
  <source src="video-tag-example.mp4" type="video/mp4">
  Video tag is not supported in this browser.
</video>

height and width define the dimensions of the video player:

Example
<video controls width="400" height="300">
  <source src="video-tag-example.mp4" type="video/mp4">
  Video tag is not supported in this browser.
</video>

loop specifies whether the video will start over after it ends:

Example
<video controls loop width="400" height="300">
  <source src="video-tag-example.mp4" type="video/mp4">
  Video tag is not supported in this browser.
</video>

muted specifies whether the audio of the video should be muted when it’s loaded:

Example
<video controls muted width="400" height="300">
  <source src="video-tag-example.mp4" type="video/mp4">
  Video tag is not supported in this browser.
</video>

poster specifies whether a certain image will be shown while the video is loading:

Example
<video controls poster="/images/video-tag.gif" width="400" height="300">
  <source src="video-tag-example.mp4" type="video/mp4">
  Video tag is not supported in this browser.
</video>

preload specifies how a video should load when the page is loaded:

Example
<video controls preload="none" width="400" height="300">
  <source src="video-tag-example.mp4" type="video/mp4">
  Video tag is not supported in this browser.
</video>

Note: there are three possible preload values: none (no preload), metadata (preloads only the metadata) and auto (the whole file is preloaded).

src defines an URL source of the video file:

Example
<video src="video-tag-example.mp4" controls width="400" height="300">
  <track kind="subtitles" src="video-tag.en.vtt" srclang="en" label="English">
  Video tag is not supported in this browser.
</video>

Note: src also supports multiple tracks to include subtitles.

Browser support

Chrome
3+
Edge
All
Firefox
3.5+
IE
9+
Opera
10.5+
Safari
3.1+

Mobile browser support

Chrome
All
Firefox
4+
Opera
All
Safari
All
Basics
Introduction
Syntax
Editors
Basic Examples
Head Section
<!DOCTYPE>
Tags and Elements
Semantic Elements
Tags Reference
Attributes
Comments
Block and Inline Elements
Forms
Form Elements
Input
Responsive Web Design
Inline Scripts
Uniform Resource Locator
Redirect
XHTML
Geolocation
Drag and Drop
Local Storage
Web Workers
Server-Sent Events
Character Encoding
Text Formatting
Quotation and Citation Elements
Headings
Paragraphs
Links
Tables
Lists
Symbols
Space
Tab
Styles
Computer Code
Layout
Classes
Colors
Images
iframes
Audio Player
Video Player
YouTube Videos
Multimedia
Canvas
SVG
<!-- -->
<a>
<abbr>
<acronym> DEPRECATED
<address>
<applet> DEPRECATED
<article>
<aside>
<audio>
<b>
<base>
<basefont> DEPRECATED
<bdi>
<bdo>
<big> DEPRECATED
<blink> DEPRECATED
<blockquote>
<body>
<br>
<button>
<canvas>
<caption>
<center> DEPRECATED
<cite>
<code>
<col>
<colgroup>
<datalist>
<dd>
<del>
<details>
<dfn>
<dialog>
<dir> DEPRECATED
<div>
<dl>
<dt>
<em>
<embed>
<fieldset>
<figcaption>
<figure>
<font> DEPRECATED
<footer>
<form>
<frame> DEPRECATED
<frameset> DEPRECATED
<h1> – <h6>
<head>
<header>
<hr>
<html>
<i>
<iframe>
<img>
<input>
<ins>
<kbd>
<keygen> DEPRECATED
<label>
<legend>
<li>
<link>
<main>
<map>
<mark>
<menu>
<menuitem> DEPRECATED
<meta>
<meter>
<nav>
<noframes> DEPRECATED
<noscript>
<object>
<ol>
<optgroup>
<option>
<output>
<p>
<param>
<pre>
<progress>
<q>
<rp>
<rt>
<ruby>
<s>
<samp>
<script>
<section>
<select>
<small>
<source>
<span>
<strike> DEPRECATED
<strong>
<style>
<sub>
<summary>
<sup>
<table>
<tbody>
<td>
<tfoot>
<th>
<thead>
<time>
<title>
<tr>
<track>
<tt> DEPRECATED
<u>
<ul>
<var>
<video>
<wbr>