The audio element

Before HTML5, the audio files could not be played on a web page without support of third party plug-ins like Adobe Flash Player, Apple QuickTime Player etc. But HTML5 defines a new element (<audio>) which provides native audio playback support in the browser. The audio tag specifies a way to embed an audio file within a web page.

Important point need to be remembered:

HTML5 audio element is supported by latest versions of all web browsers. Internet Explorer 8 or earlier versions of Internet Explorer do not support audio element.

There is an example of HTML5 audio element given below:

<audio controls="controls" loop="loop" autoplay="autoplay" preload="none">
<source src="song.mp3" type="audio/mpeg">
<source src="song.ogg" type="audio/ogg">
Your browser does not support the audio element.

The text written between <audio> and </audio> tags is displayed if the browser does not support audio element.

HTML5 Audio Tags

It defines the sound content
It defines the attributes of media resource
Supported Audio Formats with Mime Types
Presently three audio file formats are supported by HTML5 audio element.

Attributes of Audio Element with Functionality

The control attribute adds an default audio control with options like play, stop, pause, volume
The src attribute defines a valid source path of audio file
The loop attribute specifies whether the audio file should be repeatedly played
The autoplay attribute helps to start playing of an audio file automatically
The preload attribute specifies when the audio file gets preloaded. Possible values are – none / metadata / auto.
Browser List with Supported Audio File Types

Internet Explorer 9+
Firefox 3.6+
Wav, Ogg
Chrome 6+
MP3, Wav, Ogg
Safari 5+
MP3, Wav
Opera 10+
Wav, Ogg
Press CTRL+D to bookmark this page - The audio element

One Response to <audio>

  1. M Nur Khozin says:

    I like your website.

Your comment


2 + 8 =