Open In App

HTML <video> autoplay Attribute

Last Updated : 06 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

HTML <video> autoplay attribute is used to specify that the video will play automatically after loading the web page. It is the Boolean value, this attribute is new in HTML5. 

Syntax:

<video src="" autoplay>

HTML <video> autoplay attribute Examples

Example: Here is the basic implementation of the HTML <video> autoplay attribute, the autoplay attribute triggers automatic playback of the video when the page loads.

html




<!DOCTYPE html>
<html>
<head>
    <title>HTML video autoplay Attribute</title>
</head>
<body>
        <h3>HTML video autoplay Attribute Example</h3>
        <!-- HTML video autoplay Attribute -->
        <video width="400" height="200" controls autoplay>
            <source src=
                    type="video/mp4">
            <source src=
                    type="video/ogg">
        </video>
</body>
</html>


Output: In this example, we contain a <video> element with the autoplay attribute. The video is provided with controls for users to play, pause, and adjust volume. Users can interact with the video as needed, enhancing the viewing experience.

HTML-video-autoplay_attribute

HTML video autoplay Attribute Example Output

Note: Always specify the width and the height of the video else web page will be confused that how much space that video will be required due to that reason web page become slow down.

HTML video autoplay Attribute Related Questions

1. How to insert video in web page and play it using HTML ?

To insert and play a video in a web page using HTML, use the <video> tag with a specified video source and optional attributes like `autoplay` and controls.

2. How to display video controls in HTML ?

HTML <video> controls attribute is used to display video controls in HTML.  It is the Boolean value. 

Supported Browsers



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads