Menu
Media & Embedded Content

<audio> Tag

Embed sound files with playback controls.

1Adding Audio

Like video, use multiple <source> tags so every browser gets a format it supports. Avoid autoplay with sound — it is blocked by default.

Example Code
css
<audio controls>
  <source src="song.mp3" type="audio/mpeg" />
  <source src="song.ogg" type="audio/ogg" />
  Your browser does not support audio.
</audio>

2Put the element in context

An audio player supplies controls but does not supply a transcript of the content. People may be unable to hear it or may prefer reading. Avoid unexpected autoplay, and give the recording a descriptive introduction so the visitor knows what they are starting.

3Practice with a small page

Embed a short permitted audio file with controls and an adjacent transcript. Test play, pause, and volume using the available input methods. Check the fallback explanation when the file is unavailable and avoid placing the only instructions inside the recording.

Finished reading?

Mark this topic as complete to track progress.