html tutorial - autoplay Attribute in HTML - html5 - html code - html form



  • autoplay attribute is a Boolean attribute.
  • The audio and video files are automatically start playing as soon as possible while the HTML page load.

Syntax for autoplay attribute in HTML:

<audio controls autoplay>content here</audio>

Differences between HTML 4.01 and HTML5 for autoplay attribute:

HTML 4.01

  • HTML4 does not support <audio> and <video> tag.

HTML5

  • <audio> and <video> tags are new in HTML5.

Applies to:

Elements Attribute
<audio> autoplay
<video> autoplay

Sample coding for autoplay attribute in HTML:

Tryit<!DOCTYPE html>
<html>
    <body>
        <audio controls autoplay>
            <source src="welcome.wav" type="audio/wav">
            <source src=”welcome.mp3" type="audio/mp3">
        </audio>
    </body>
</html>

Code Explanation for autoplay attribute in HTML:

autoplay Attribute Code Explanation

  1. autoplay attribute is used to play the audio file automatically without user interaction.

Output for autoplay attribute in HTML:

autoplay Attribute Output

  1. The output shows that the audio file played automatically while the page load.

Browser Support for autoplay attribute in HTML:

4.0 9.0 3.5 4.5 10.5

Related Searches to autoplay Attribute in html