Name

audio — HTML5

Synopsis

<audio> . . . </audio>

Embeds a sound file media in the web page without requiring a plug-in. The content of the audio element can be used by agents that don’t support the element.

Notes

HTML5 only. There is still debate regarding the supported audio format for the audio element (mainly open source Ogg Vorbis versus proprietary, yet more popular, formats such as .mp3). It is currently supported by Firefox 3.5+, Safari 3.2+, and Opera 10.0+. Chrome support is upcoming. Internet Explorer has not published plans to support audio.

Start/End Tags

Required/Required

Attributes

HTML5 Global Attributes

autobuffer (or autobuffer="autobuffer" in XHTML5)

Tells the user agent (browser) that the media file is likely to be used and should be readily available

autoplay (or autoplay="autoplay" in XHTML5)

Plays the media file automatically

controls (or controls="controls" in XHTML5)

Indicates that the user agent (browser) should display a set of playback controls for the media file

loop (or loop="loop" in XHTML5)

Indicates that the media file should start playing again automatically once it reaches the end

src="URL"

Specifies the location of the media file

Examples

See also source.

<audio src="beachmusic.ogg" autoplay controls>
  This browser doesn't support <code>audio</code> elements.
</audio>

Get HTML & XHTML Pocket Reference, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.