HTML Tags

HTML5 <audio> Tag

The <audio> tag embeds sound content, such as music or podcasts, with optional built-in playback controls.


What is the <audio> tag?

The <audio> element, introduced in HTML5, plays audio natively in the browser without a plug-in. You can point it at a file with the src attribute or provide multiple <source> children so the browser can pick a format it supports. Text inside the element is fallback content for very old browsers.

Complete example

<!DOCTYPE html>
<html lang="en">
  <body>
    <audio controls>
      <source src="song.ogg" type="audio/ogg" />
      <source src="song.mp3" type="audio/mpeg" />
      Your browser does not support the audio element.
    </audio>
  </body>
</html>

Attributes

AttributeDescription
srcURL of the audio file (alternative to using <source> children).
controlsShows the browser's built-in play, pause, and volume controls.
autoplayStarts playing as soon as it can (often blocked unless muted).
loopRestarts the audio from the beginning when it ends.
mutedStarts the audio muted.
preloadHints how much to preload: none, metadata, or auto.
⚠️

Most browsers block autoplay of audio with sound. If you need autoplay, the audio usually must be muted. Always provide controls for accessibility.

The <audio> tag is supported in all modern browsers. Provide MP3 plus at least one open format such as OGG for the broadest compatibility.

Ready to use your HTML skills?

Find web development internships and fresher jobs across India.

Browse Web Dev Internships