In this HTML tutorial, we will discuss the HTML audio tag. In this article, we will discuss how to use the audio tag in HTML.
What is an audio tag?
Basic Syntax
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML TUTORIAL</title>
</head>
<body>
<audio controls>
<source src="audio-file.mp3" type="audio/mpeg">
</audio>
</body>
</html>
Attributes of the <audio> Tag
<audio controls>
<source src="audio-file.mp3" type="audio/mpeg">
</audio>
<audio autoplay>
<source src="audio-file.mp3" type="audio/mpeg">
</audio>
<audio controls loop>
<source src="audio-file.mp3" type="audio/mpeg">
</audio>
<audio controls muted>
<source src="audio-file.mp3" type="audio/mpeg">
</audio>
<audio controls preload="auto">
<source src="audio-file.mp3" type="audio/mpeg">
</audio>
Fallback Content
<audio controls>
<source src="audio-file.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<p>If you are seeing this, your browser does not support the audio tag.</p>