Last Updated : 23 Jul, 2025
The HTML <audio> element is used to add audio content to a webpage, allowing you to play music, sound effects, or other audio files directly in the browser.
Syntax<audio>HTML
<source src="sample.mp3" type="audio/mpeg">
</audio>.
<!DOCTYPE html>
<html lang="en">
<body>
<audio>
<source src=
"https://media.geeksforgeeks.org/wp-content/uploads/20241009180552641558/sample-12s.mp3" type="audio/mp3">
<source src="" type="audio/ogg">
</audio>
</body>
</html>
Functionality of HTML AudioThe <audio> supports the global attributes and event attributes.
More Examples of HTML Audio
Basic Autoplay Audio HTML
<html lang="en">
<body>
<audio autoplay>
<source src="https://media.geeksforgeeks.org/wp-content/uploads/20241009180552641558/sample-12s.mp3"
type="audio/mpeg">
</audio>
</body>
</html>
To learn more about the HTML audio autoplay attribute, click here Link
Autoplay Audio with Controls and Styling HTML
<!DOCTYPE html>
<html lang="en">
<head>
<style>
audio {
display: block;
margin: 20px auto;
width: 80%;
}
</style>
</head>
<body>
<audio controls autoplay>
<source src=
"https://media.geeksforgeeks.org/wp-content/uploads/20241009180552641558/sample-12s.mp3" type="audio/mpeg">
</audio>
</body>
</html>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4