Skip to main content
D
HTML
HTML Audio

HTML Audio

HTML audio tags embed playable sound files onto the page.

Read Time
5 min read
Difficulty
Beginner
Last Updated
Jun 15, 2026
Version
v1.0.0

Introduction

HTML uses the `

Syntax

Syntax
1<!-- audio syntax -->
2<audio controls>
3  <source src="song.mp3" type="audio/mpeg">
4</audio>

Example

Example
1<!-- this embeds audio -->
2<!DOCTYPE html>
3<html lang="en">
4  <head>
5    <meta charset="UTF-8">
6    <meta name="viewport" content="width=device-width, initial-scale=1.0">
7    <title>Audio</title>
8  </head>
9  <body>
10    <audio controls>
11      <source src="music.mp3" type="audio/mpeg">
12    </audio>
13  </body>
14</html>

Try it Yourself

Hands-on Practice
Modify the code below to see how it affects the output. This is the best way to learn!
Interactive Editor
1234567891011121314151617181920
Live Preview

Key Points

  • The `
  • The `controls` attribute adds a play button.
  • The `loop` attribute restarts the track automatically.
  • MP3 files offer the best cross-browser support.