HTML Video


The HTML element <video> is used to display a video on a webpage.

How it Works

The controls attribute includes video options such as play, pause, and volume.

It's smart to consistently include the width and height attributes. Without setting these attributes, the webpage may flicker as the video is being loaded.

The <source> part helps you choose different video files for the browser to pick from. The browser will go with the first format it recognizes.

The content enclosed by the <video> and </video> tags will show up exclusively on web browsers that do not have compatibility with the <video> feature.


HTML <video> Autoplay

To make a video play automatically, simply employ the autoplay attribute:

Insert muted right after autoplay to enable automatic video playback with muted audio.


HTML Video - Methods, Properties, and Events

The HTML DOM provides ways to control the <video> element by specifying its actions, characteristics, and triggers.

You can use this code to load, play, and pause videos. Additionally, you can set the duration and volume as needed.

There are events in the Document Object Model (DOM) that can let you know when a video starts playing, is paused, and so on.