HTML Audio

The HTML <audio> element is used to play an audio file on a web page.

HTML <audio> Element

Example :

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

The controls attribute adds audio controls, like play, pause, and volume.

The newly introduced HTML5 <audio> element provides a standard way to embed audio in web pages.


Attribute Value Description
autoplay autoplay Plays the audio file automatically after loading the page.
controls controls Specifies that audio controls should be displayed (Play/ Pause)
loop loop Specifies that the audio will start over again, every time it is finished
muted muted Specifies that the audio output should be muted
preload auto
Specifies if and how the author thinks the audio should be loaded when the page loads
src URL Specifies the URL of the audio file