HTML

HTMLAudioElement

HTMLAudioElement <audio>

The <audio> elements' properties can be accessed using the HTMLAudioElement interface, along with tools for modifying them. Music or other audio streams can be embedĀ in a document by using the <audio> tag. One or more "source" tags with various audio sources are contained in the "audio" tag. The first source supported by the browser will be used. Only browsers that do not support the <audio> element will display the text in between the audio> and /audio> tags. MP3, WAV, and OGG are the three audio formats that HTML supports.

Attribute Value Description Example
autoplay autoplay Specifies that the audio will start playing as soon as it is ready <audio controls autoplay> <source src="horse.ogg" type="audio/ogg"> <source src="horse.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio>
controls controls Specifies that audio controls should be displayed (such as a play/pause button etc) The controls attribute is a boolean attribute. When present, it specifies that audio controls should be displayed. Audio controls should include:Play,Pause,Seeking,Volume <audio controls> <source src="horse.ogg" type="audio/ogg"> <source src="horse.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio>
loop loop Specifies that the audio will start over again, every time it is finished <audio controls loop> <source src="horse.ogg" type="audio/ogg"> <source src="horse.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio>
muted muted Specifies that the audio output should be muted <audio controls muted> <source src="horse.ogg" type="audio/ogg"> <source src="horse.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio>
hreflang language_code Specifies the language of the target URL <map name="planetmap"> <area shape="rect" coords="0,0,82,126" alt="Sun" href="sun.htm" hreflang="en"> </map>
preload auto Specifies if and how the author thinks the audio should be loaded when the page loads <audio controls preload="none"> <source src="horse.ogg" type="audio/ogg"> <source src="horse.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio>
metadata
none
src URL Specifies the URL of the audio file <audio src="horse.ogg" controls> Your browser does not support the audio element. </audio>

Browser Compatibility

Element Chrome Edge Firefox Safari Opera
<audio> Yes Yes Yes Yes Yes