Elements – Audio Tag

Audio Tag

The <audio> tag defines an audio element, that can be used to add audio media resource to an HTML document that will be played by native support for audio playback built into the browser rather than a browser plugin.

The audio tag currently supports three file formats OGG, MP3 and WAV which can be added to your html as follows.

Adding an OGG
<audio controls> <source src="file.ogg" type="audio/ogg"> </audio>
Adding an MP3
<audio controls> <source src="file.mp3" type="audio/mpeg"> </audio>
Adding a WAV
<audio controls> <source src="file.wav" type="audio/wav"> </audio>

It may contain one or more audio sources, represented using the src attribute or the source element.

Adding Multiple Audio Files
<audio controls> <source src="file-1.wav" type="audio/wav"> <source src="file-2.ogg" type="audio/ogg"> <source src="file-3.mp3" type="audio/mpeg"> </audio>

Browser Support for different filetypes is as follows

Internet ExplorerYesNoNo
Google ChromeYesYesYes
Mozilla FirefoxYesYesYes

Supported Attributes

autoplayautoplayThe audio will start playing as soon as it is ready
controlscontrolsaudio will be displayed (such as a play/pause button etc)
looploopaudio will start over again, every time it is finished
mutedmutedaudio output will be muted
srcURLSpecifies the URL of the audio file

More Information:


This article needs improvement. You can help improve this article. You can also write similar articles and help the community.