HTML Video

The <video> tag is used to embed video content on a webpage. It allows you to stream video files directly in the browser without needing additional plugins. HTML5 supports three main video formats:

MP4: Widely supported format with high compatibility.

WebM: Open, royalty-free format optimized for the web.

OGG: Open format that can be used for video playback.

Example:

<video src="movie.mp4" controls autoplay loop muted poster="poster.jpg" preload="auto" width="640" height="360">
Your browser does not support the video tag.
</video>

Attribute Description
src Specifies the path to the video file. It is used to define the source of the video content.
controls Adds video playback controls such as play, pause, and volume. This attribute is boolean; if present, the controls will be displayed.
autoplay If present, the video will start playing automatically as soon as it is loaded.
loop If present, the video will loop continuously once it finishes playing.
muted If present, the video will be muted by default.
poster Specifies an image to be shown while the video is downloading or until the user hits the play button.
preload Specifies if and how the video file should be preloaded when the page loads. Possible values are:
  • auto: The browser may preload the entire video file.
  • metadata: Only metadata (e.g., duration) will be preloaded.
  • none: The video file will not be preloaded.
width Specifies the width of the video player in pixels.
height Specifies the height of the video player in pixels.