asp.net.ph

Skip Navigation LinksHome > Abakada: Back to Basics > Language References > HTML Elements > AUDIO Element

<audio> Element


Embeds audio content in an HTML document.HTML 5

HTML Syntax

NOTE: Both start and end tags are required.

Remarks

The <audio> element is used to embed sound content in an HTML document, without requiring any third-party plug-in or involve complex scripting.

In its simplest form, the src attribute is required, which specifies the location of the audio file to embed.

<audio src="music.mp3" ...></audio>

Alternatively, authors can use the <source> element, as it allows for multiple alternative options.

A <source> tag specifies an audio file, which can be any of three supported audio formats in HTML: MP3, WAV, and OGG.

The <source> tags are defined as child elements of the <audio>...</audio> tag.

<audio ...>
   <source src="music.mp3" ...>
   <source src="music.ogg" ...>
</audio>

The browser plays the first source it supports.

A download link or some “fallback” text can be defined within the <audio>...</audio> tags, to provide alternate content in cases where the browser does not support the audio element or the audio content, or somehow failed to download the audio source file.

<audio src="music.mp3" ...>
   Sorry, your browser does not support audio playback.
   http://somewhere.com/media/music.mp3
</audio>

Attributes

The <audio> element supports the following attributes, in addition to global attributes common to all HTML elements.

AttributeValueDescription
autoplayautoplaySpecifies that the audio will start playing as soon as it is ready
controlscontrolsSpecifies that audio controls should be displayed (such as a play/pause button etc)
looploopSpecifies that the audio will start over again, every time it is finished
mutedmutedSpecifies that the audio output should be muted
preloadauto, metadata, noneSpecifies if and how the author thinks the audio should be loaded when the page loads
srcURLSpecifies the URL of the audio file

Example

The following example shows how the <audio> element may be used.

<audio controls>
   <source src="happy-day.mp3" type="audio/mpeg">
   Sorry, your browser does not support the audio element.
</audio>

which would render on a Web page as follows:

External References

See Also

EMBED   OBJECT   PICTURE   SOURCE   VIDEO



Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note