html
  1. html-video-tag

HTML <video> Tag

The HTML <video> tag is used to embed videos into web pages. It allows you to display videos on your website without requiring any plugins or third-party software.

Syntax

<video src="path-to-video" width="width" height="height" controls></video>
  • src: The path to the video file.
  • width: The width of the video player in pixels.
  • height: The height of the video player in pixels.
  • controls: Displays the default video playback control.

Example

  <video src="video.webm" width="500" height="300" controls></video>
Try Playground

Explanation

The HTML <video> tag is used to embed a video into the web page. The src attribute is used to specify the path to video file. The width and height attributes specify the dimensions of the video player. With the controls attribute, the user can control playback and adjust the volume of the video.

It is also possible to add other attributes like autoplay to allow the video to start playing as soon it loads, loop to play the video repeatedly, muted to silence the sound or poster to specify an image to be displayed before the video starts playing.

Use

The HTML <video> tag is used when you want to add multimedia content, such as video, to a web page. It is commonly used on sites where video tutorials, promotional videos, product demos, or any other type of video content need to be displayed.

Important Points

  • The HTML <video> tag requires the video file to be in a supported format such as MP4, WebM, or Ogg.
  • The autoplay attribute is sometimes disabled by browsers to prevent annoying or unwanted auto-play videos that can affect the user experience.
  • The width and height attributes should be adjusted according to the aspect ratio of the video file to avoid distortion.
  • The HTML <video> tag is not supported by some older browsers.

Summary

HTML <video> Tag is used to embed videos into web pages. It allows you to display videos on your website without requiring any plugins or third-party software. With the help of various attributes like src, width, height, controls, autoplay, and poster, web developers can customize the video player according to their needs.

Published on: