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
<!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:
Supported Browsers:
- Google Chrome 4
- Edge 9
- Firefox 3.5
- Safari 4
- Opera 11.5