HTML audio Tag autoplay Attribute Tutorial

In this section, we will learn what autoplay attribute in HTML <audio> tag is and how it works.

What is autoplay Attribute in HTML audio Tag?

When adding an audio to a webpage via HTML <audio> tag, you have the option to choose whether the audio should play automatically after loading or it should wait for users to hit the play button first.

This is done with the autoplay attribute.

If we put this attribute to <audio> element, browsers will play the audio file automatically without the need of users to hit the play button first.

HTML autoplay Attribute in audio Tag Syntax:

<audio autoplay> </audio>

audio Tag autoplay Attribute Values

This attribute does not take a value! Simply put, the attribute in the opening tag of HTML <audio> and that’s it, the audio will be automatically played.

Example: using autoplay attribute in HTML audio tag

See the Pen using autoplay attribute in HTML audio tag by Omid Dehghan (@odchan1) on CodePen.

Facebook
Twitter
Pinterest
LinkedIn

Top Technologies