logo Learn HTML
  • Home
  • Tutorials
  • Practice
  • Quiz
  • Projects
  • About
  • Contact

HTML Course

  • HTML HOME
  • HTML Introduction
  • HTML Basic
  • HTML Element
  • HTML Attributes
  • HTML Headings
  • HTML Paragrapha
  • HTML Style
  • HTML Formattin
  • HTML Quotations
  • HTML Colors
  • HTML Css
  • HTML Links
  • HTML Image
  • HTML Favicon
  • Page Tittle
  • HTML Tables
  • HTML Lists
  • Block & Inline
  • HTML Div
  • HTML Classes
  • HTML Id
  • HTML Buttons
  • HTML Iframes
  • HTML File Paths
  • HTML Head
  • HTML Layout
  • HTML Symbols
  • HTML Emojis
  • HTML URL Encode
  • HTML VS XHTML
  • HTML FROM
  • HTML Form
  • Form Attributes
  • Form Elements
  • HTML Input Types
  • HTML Input Attributes
  • Input Form Attributes
  • HTML Graphics
  • HTML Canvas
  • HTML SVG
  • HTML Media
  • HTML Media
  • HTML Video
  • HTML Audio
  • HTML Plug-ins
  • HTML Youtube
  • HTML APIS
  • HTML Web APIS
  • HTML Geolocation
  • HTML Drag & Drop
  • Web Storage
  • Web Workers
  • HTML SSE
  • HTML Examples
  • HTML Examples
  • HTML Editor
  • HTML Quiz
  • HTML Exercises
  • HTML References
  • HTML Tag List
  • HTML Attributes
  • HTML Global Attributes
  • HTML Brower Support
  • HTML Events
  • HTML Colors
  • HTML Canvas
  • HTML Audio & Video
  • HTML Doctypes
  • HTML Character Sets
  • HTML URL Encode
  • Language Codes
  • HTTP Messages
  • HTTP Methods
  • PX to EM Converter
  • keyboard Shortcuts

HTML Video

The HTML <video> element is the standard way to embed video content or movies directly into your web pages without needing external plugins.


The <video> Element

To display a video, you use the <video> tag combined with the <source> tag.

Basic Example:

<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">

Your browser does not support the video tag.

</video>

How it Works:

  • controls: Adds buttons for Play, Pause, and Volume.

  • width & height: Always define these to prevent the page layout from "flickering" or jumping while the video loads.

  • <source>: Allows you to list multiple formats. The browser will automatically play the first one it supports.

  • Fallback Text: The text "Your browser does not support..." only appears if the user is using a very old browser.


Autoplay and Muting

You can make a video start automatically using the autoplay attribute.

Important Note: Most modern browsers (like Chrome and Edge) block autoplay with sound to improve user experience. To guarantee a video autoplays, you must add the muted attribute

Basic Example:

<video width="320" height="240" autoplay muted >
<source src="movie.mp4" type="video/mp4">
</video>

Supported Video Formats

There are three main formats supported by the HTML standard: MP4, WebM, and Ogg.

Browser MP4 WebM Ogg
Chrome / Edge Yes Yes Yes
Firefox Yes Yes Yes
Safari Yes Yes No
Opera Yes Yes Yes

Media Types (MIME Types):

  • MP4: video/mp4

  • WebM video/webm

  • Ogg: video/ogg


JavaScript Interaction (DOM)

The HTML DOM provides methods and properties that allow you to control the video player using JavaScript. You can create your own custom "Play" or "Pause" buttons.

  • Methods: play(), pause(), load()

  • Properties: duration, volume, paused, currentTime


HTML Video Tag Reference

Tag Description
<video> Defines a video or movie container.
<source> Defines multiple media resources for <video> and <audio>
<track> Used for subtitles, caption files, or other text tracks.

Try It Your Self

Sign Up For New
Update

HTML Basic
  1. HTML Basic
  2. HTML Element
  3. HTML Attributes
  4. HTML Headings
  5. HTML Paragrapha
  6. HTML Tables
  7. HTML Lists
HTML Advance
  1. HTML Div
  2. HTML Classes
  3. HTML Id
  4. HTML Buttons
  5. HTML Iframes
  6. HTML Symbols
  7. HTML Emojis