HTML autoplay attribute

HTML autoplay attribute sets the media source to play automatically after the page is loaded.

<p>This media plays automatically after page is loaded.</p>
<video src="files/Hummingbird.mp4"  height="300" width="300" controls>
</video>
</>

This media plays automatically after page is loaded.

Attribute values

All possible values of autoplay attribute

autoplay is a boolean attribute that has only two states.

Related Tags

The tags that support autoplay attribute

<video> tag

video tag adds video in a page. video supports autoplay attribute.

<p>This video plays automatically after page is loaded.</p>
<video src="files/Hummingbird.mp4"  height="300" width="300" autoplay>
 </video>
Try</>

<audio> tag

audio tag adds audio stream in a page. autoplay attribute is also applicable on the audio tag.

<p>This audio plays automatically after page is loaded.</p>
<audio src="files/sample.mp3"  height="200" width="200" autoplay>
 </audio>
Try</>


Was this article helpful?