Follow The New Tutorial updates on WhatsApp, Telegram or YouTube.

HTML Video Tag

The <video> tag is used to embed video content in a document. It is used for streaming video files such as a movie clip, song clip on the web page.

HTML 5 supports <video> tag. The <video> tag contains one or more <source> tags with different video sources. 

There are three video formats supported for HTML video tag: mp4, webM and ogg.

Attributes of HTML Video Tag

AttributeDescription
controlsSpecifies that video controls should be displayed (such as a play/pause button etc).
heightIt is used to set the height of the video player.
widthIt is used to set the width of the video player.
posterSpecifies an image to be shown while the video is downloading, or until the user hits the play button. URL for an image to be shown while the video is downloading.
autoplayA Boolean attribute; if specified, the video automatically begins to play back as soon as it can do so without stopping to finish loading the data.
loopIf specified the video file will start over again, every time when it is completed.
mutedIt is used to mute the video output.
preloadSpecifies if and how the author thinks the video should be loaded when the page loads. Possible values are: auto, metadata and none.
srcIt specifies the source URL of the video file.
Attributes of HTML Video Tag

The text between the <video> and </video> tags will only be displayed in browsers that do not support the <video> element.

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HTML video element</title>
</head>

<body>
    <h1>The video element</h1>

    <video width="320" height="240" controls>
        <source src="https://eywiah.com/wp-content/uploads/2021/12/movie.mp4" type="video/mp4">
        Your browser does not support the video tag.
    </video>
</body>

</html>
HTML video element example – Output

MIME Types for HTML Video format

Video FormatMIME Type
mp4video/mp4
oggvideo/ogg
webMvideo/webM
MIME Types for HTML Video format