VOOZH about

URL: https://www.geeksforgeeks.org/html/how-to-add-autoplay-video-in-html/

⇱ Add Autoplay Video in HTML - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Add Autoplay Video in HTML

Last Updated : 29 May, 2026

Web design often has a feature of including a video that starts to play as soon as the web page loads. This effect can be achieved using HTML5<video> element with the autoplay attribute. In this way, videos start playing without any user interaction hence improving the multimedia experience on websites.

Approach

  • HTML5 <video> element is utilized to insert video in your web page directly it supports different attributes that define how the video should be displayed and played.
  • This will enable videos to begin playing automatically as soon as the webpage opens by adding an autoplay attribute to the <video>.
  • use the <source> element within the <video> tag to specify your video file. The src attribute denotes where exactly your video files are located while the type attribute shows its MIME type.
  • With controls attributes included, various playback functions like play, pause, volume control among others will be available for users.

Syntax:

<video autoplay controls> 
<source src="video.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>

Example 1: The example below shows how to add an autoplay video in HTML. The <video> tag includes the autoplay and controls attributes, enabling the video to start playing automatically with user controls for playback.

Example 2: The example below shows how to add an autoplay video in HTML with the muted attribute. The <video> tag includes autoplay and muted attributes, enabling the video to start playing automatically without sound.

Comment
Article Tags:
Article Tags: