HTML autoplay attribute

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

Example

<p>This media plays automatically after page is loaded.</p>
<video src="test.mkv"  height="300" width="300" controls>
</video>
Try </>

autoplay attribute value

autoplay is a boolean attribute that has only two states.

Related Tags

The tags that support autoplay attribute are given below.

<video> tag

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

Example

<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.

Example

<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?

 

Email:

Message:

Get the newsletter