HTML5 provides a standard for playing audio files.

Audio on the Web

Until now, there has not been a standard for playing audio files on a web page.
Today, most audio files are played through a plug-in (like flash). However, different browsers may have different plug-ins.
HTML5 defines a new element which specifies a standard way to embed an audio file on a web page: the <audio> element.

How It Works

To play an audio file in HTML5, this is all you need:

Example


<!DOCTYPE html>

<html>
<body>

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

</body>
</html>

Try it yourself in Notepad or Dreamweaver by coping and pasting the code above.

The control attribute adds audio controls, like play, pause, and volume.
You should also insert text content between the <audio> and </audio> tags for browsers that do not support the <audio> element.
The <audio> element allows multiple <source> elements. <source> elements can link to different audio files. The browser will use the first recognized format.

Audio Formats and Browser Support

Currently, there are 3 supported file formats for the <audio> element: MP3, Wav, and Ogg:
BrowserMP3WavOgg
Internet Explorer 9YESNONO
Firefox 4.0NOYESYES
Google Chrome 6YESYESYES
Apple Safari 5YESYESNO
Opera 10.6NOYESYES


HTML5 audio Tags

TagDescription
<audio>Defines sound content
<source>Defines multiple media resources for media elements, such as <video> and <audio>

One Response so far.

  1. Unknown says:

    Html 5 is a dynamic update version of Html 5.It brings new features which bring revolution in Markup language.
    Most important is web form,canvas,animation,web storage,Geolocation etc
    You can find nice tutorial about html5 from http://www.learnhtml5today.blogspot.com

Leave a Reply