Language
日本語
English

Caution

JavaScript is disabled in your browser.
This site uses JavaScript for features such as search.
For the best experience, please enable JavaScript before browsing this site.

  1. Home
  2. HTML Tag Dictionary
  3. <audio>

<audio>

The audio element embeds audio content in an HTML page, allowing browsers to play background music, sound effects, podcasts, and more.

Syntax

<!-- Basic audio embedding -->
<audio src="sound.mp3" controls></audio>

<!-- Multiple formats with fallback -->
<audio controls>
  <source src="sound.ogg" type="audio/ogg">
  <source src="sound.mp3" type="audio/mpeg">
  <p>Your browser does not support audio playback.</p>
</audio>

Common Attributes

AttributeDescription
srcSpecifies the URL of the audio file to play.
controlsDisplays the browser's built-in playback controls, including play/pause, volume, and a seek bar.
autoplayStarts playback automatically when the page loads. Many browsers restrict this behavior.
loopRestarts playback from the beginning when the audio ends.
mutedMutes the audio on playback.
preloadSpecifies how the browser should preload the audio data (none / metadata / auto).

Sample Code

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>audio Sample</title>
</head>
<body>

  <p>BGM Player</p>

  <!-- Audio with playback controls -->
  <audio controls>
    <!-- Prefer OGG; fall back to MP3 if not supported -->
    <source src="bgm.ogg" type="audio/ogg">
    <source src="bgm.mp3" type="audio/mpeg">
    <p>Your browser does not support audio playback.</p>
  </audio>

  <p>Looping Audio Sample</p>

  <!-- Audio that loops continuously -->
  <audio src="ambient.mp3" controls loop></audio>

</body>
</html>

Result

An audio control panel appears on the page, allowing you to play, pause, adjust volume, and seek through the audio.

┌──────────────────────────────────────┐
│  ▶  0:00 ──────────────────  🔊     │
└──────────────────────────────────────┘

Notes

The audio element was introduced in HTML5, enabling browsers to play audio without plugins such as Flash. MP3 (audio/mpeg) is now supported by virtually all browsers. OGG is an open format that can offer better quality than MP3 in some cases, but Safari's support for it is limited. To maximize compatibility, specify both formats using multiple source elements.

Even when autoplay is set, most browsers block audio autoplay without prior user interaction. Use autoplay sparingly to avoid a poor user experience. For use cases such as background music, it is recommended to include the controls attribute so users can start playback themselves.

To embed video content, use the video element instead.

Browser Compatibility

Chrome Chrome
49+
2 or earlier ×
Firefox Firefox
57+
2.5 or earlier ×
Safari Safari
18+
3 or earlier ×
Edge Edge
80+
11 or earlier ×
IE IE
11+
8 or earlier ×
Opera Opera
48+
10 or earlier ×
iOS Safari iOS Safari
18+
2 or earlier ×
Android Browser Android Browser
37+
2 or earlier ×
Chrome Android Chrome Android
36+
17 or earlier ×
Firefox Android Firefox Android
79+
3 or earlier ×

If you find any errors or copyright issues, please .