HTML audio tag
HTML

HTML audio tag

Mishel Shaji
Mishel Shaji

The <audio> tag is used to add audio files to the HTML page. Audio tag currently supports  MP3, WAV, and Ogg formats.

Example

<audio controls>
  <source src="audio.mp3" type="audio/mp3">
  <source src="audio.wav" type="audio/wav">
  This browser does not support audio tag.
</audio>

Attribute

AttributeValuesDescription
autoplayautoplaySpecifies that the audio will start playing as soon as it is ready.
controlcontrolSpecifies that audio controls should be displayed (such as a play/pause button etc).
looploopSpecifies that the audio should be played repeatedly or not
mutedmutedSpecifies that the audio output should be muted.
preloadSpecifies if and how the author thinks the audio should be loaded when the page loads.
srcURLSpecifies the URL of the audio file.

Things to remember

  • Most browsers support MP3 format.
  • The text provided in the audio tag will be displayed if the browser does not support audio tag.