HTML Tag Reference - HTML tag <audio>








The <audio> element embeds audio content into an HTML document. You specify the audio source using the src attribute.

Browser compatibility

<audio> Yes 9.0 Yes Yes Yes

What's new in HTML5

The <audio> tag is new in HTML5.

Attribute

autoplay
Value autoplay makes audio start playing as soon as it is ready
controls
audio controls should be displayed such as a play/pause button.
loop
loop the audio
muted
Value muted mutes the audio
preload
Possible values:auto|metadata|none. When to load the audio when the page loads
src
the URL of the audio file

Global Attributes

The <audio> tag supports the Global Attributes in HTML.

Event Attributes

The <audio> tag supports the Event Attributes in HTML.





Default CSS Settings

None.

Example

The following HTML code uses audio tag to include a mp3 format audio file into a HTML document

<!DOCTYPE HTML>
<html>
<body>
      <audio controls src="mytrack.mp3" autoplay> Audio content
            cannot be played
      </audio>
</body>
</html>




Provide Multiple Audio Formats

The following examples show how to use the source element to provide multiple audio formats.

<!DOCTYPE HTML>
<html>
<body>
      <audio controls autoplay>
            <source src="mytrack.ogg" />
            <source src="mytrack.mp3" />
            <source src="mytrack.wav" />
            Audio content cannot be played
      </audio>
</body>
</html>