You are here : htmlHTML 5audio

<audio> - HTML 5

The <audio> tag defines sound, such as music or other audio streams.

Currently, there are 3 supported file formats for the <audio> element: MP3, Wav, and Ogg.

ATTRIBUTES : 

  • autoplay (autoplay) : Specifies that the audio will start playing as soon as it is ready.
  • controls (controls)  : Specifies that audio controls should be displayed (such as a play/pause button etc).
  • 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,metadata,none) : 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.


Syntax

<audio> ... </audio>


Example

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


Output / Return Value


Limitations

Available only in HTML5.


Alternatives / See Also


Reference