X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

HTML <audio> Tag


Example

Play a sound:

<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>

Try it Yourself »

Definition and Usage

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:

Browser MP3 Wav Ogg
Internet Explorer YES NO NO
Chrome YES YES YES
Firefox NO
Update: Firefox 21 running on Windows 7, Windows 8, Windows Vista, and Android now supports MP3
YES YES
Safari YES YES NO
Opera NO YES YES

MIME Types for Audio Formats

Format MIME-type
MP3 audio/mpeg
Ogg audio/ogg
Wav audio/wav


Browser Support

The numbers in the table specifies the first browser version that fully supports the element.

Element
<audio> 4.0 9.0 3.5 4.0 10.5


Differences Between HTML 4.01 and HTML5

The <audio> tag is new in HTML5.


Tips and Notes

Tip: Any text inside the between <audio> and </audio> will be displayed in browsers that do not support the <audio> tag.


Attributes

= New in HTML5.

Attribute Value Description
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

Global Attributes

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


Event Attributes

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


Related Pages

HTML DOM reference: HTML Audio/Video DOM Reference



Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook