HTML Tags

HTML <audio> Tag

The <audio> tag is used to embed sound content in an HTML document, such as music, podcasts, or sound effects.
It supports multiple audio formats and provides playback controls like play, pause, and volume.

Syntax

html

<audio controls>
  <source src="audiofile.mp3" type="audio/mpeg">
  <source src="audiofile.ogg" type="audio/ogg">
  Your browser does not support the audio element.
</audio>

Attributes

AttributeDescriptionExample
srcSpecifies the path to the audio file.src="song.mp3"
controlsDisplays play, pause, and volume controls.controls
autoplayAutomatically starts playing the audio.autoplay
loopRepeats the audio after it ends.loop
mutedStarts the audio in a muted state.muted
preloadSpecifies how the audio should be loaded. Values: none, metadata, auto.preload="auto"

Example

html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Audio Tag Example</title>
</head>
<body>
  <h2>Example: Embedding an Audio File</h2>
  <audio controls preload="metadata">
    <source src="https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3" type="audio/mpeg">
    <source src="https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.ogg" type="audio/ogg">
    Your browser does not support the audio element.
  </audio>
</body>
</html>

Output

Browser Output

html

Displays a built-in audio player with play, pause, volume, and timeline controls.
Use our Try It Editor to test and hear the output with your own audio file.

Browser Support

Chrome
Edge
Firefox
Safari
Opera
IE9+
YesYesYesYesYesYes

The <audio> tag is fully supported by all major browsers.
Older browsers (IE8 and below) do not fully support HTML audio playback.
However, some IE version may support different audio formats such as MP3, OGG, or WAV.

Notes

  • You can include multiple <source> elements to ensure cross-browser compatibility.
  • If the browser doesn’t support the <audio> tag, the fallback text inside will be displayed.
  • Avoid using autoplay without user consent to prevent accessibility and UX issues.

Conclusion

The <audio> tag provides an easy and standardized way to integrate sound into web pages.
By combining multiple formats and attributes, you can create rich multimedia experiences with full browser compatibility.