Open In App

HTML <audio> autoplay Attribute

Last Updated : 30 Jan, 2024
Summarize
Comments
Improve
Suggest changes
Share
Like Article
Like
Report

The HTML <audio> autoplay attribute is used to specify that the audio should automatically start playing as soon as it is loaded. It is a Boolean attribute. 

Note: Autoplay is not allowed in most cases on Chromium browsers. However, it is allowed when muted.

Syntax: 

<audio autoplay>

Example: This example illustrates the <audio> autoplay attribute in HTML 

html
<!DOCTYPE html>
<html>

<head>
    <title>
        HTML audio autoplay Attribute
    </title>
</head>

<body style="text-align: center">

    <h1 style="color: green">
        GeeksforGeeks
    </h1>

    <h2>HTML audio autoplay Attribute</h2>

    <audio controls autoplay>
        <source src="GFG.ogg" type="audio/ogg">
        <source src=
"https://media.geeksforgeeks.org/wp-content/uploads/20231004184006/SoundHelix-Song-10.mp3"
                type="audio/mpeg">
    </audio>
</body>

</html>

Output:

gty Supported Browsers:

  • Google Chrome 4
  • Edge 9
  • Firefox 3.5
  • Safari 4
  • Opera 11.5

Similar Reads