HTML5 Audio. Sound support in HTML5 and JavaScript.

HTML5 offers us not only such wonderful elements as Canvas, but many other valuable features, facilitating the creation of on-line applications. One of them is sound support (HTML5 Audio), and additionally also video support. But the most important is that we don’t have to play around strange solutions, like Java applets; we don’t event need Flash technology.

More about HTML5 Audio

In simple words, it’s a part of HTML5 specification which allows to operate audio input, playback and sound synthesis.

It all starts with the HTML5 <audio> element.

How to use HTML5 Audio

A simple example of using audio element:

&lt;audio src=&quot;/test/myaudio.ogg&quot;&gt;
&lt;p&gt;Your browser does not support the audio element.&lt;/p&gt;

We can show the basic UI of player controls (play, volume):

&lt;audio controls&gt;
  &lt;source src=&quot;my.ogg&quot; type=&quot;audio/ogg&quot;&gt;
  &lt;source src=&quot;my.mp3&quot; type=&quot;audio/mpeg&quot;&gt;
  Your browser does not support the audio element.

It will play the supported file format or the information about the lack of audio element support in the browser.

Basic information about the support in browsers:

In addition to the controls option, we can also define autoplay and loop (playing in a loop).

Using more complex solutions

With HTML5 Audio much more advanced solutions, that we can use in our projects, could be developed.

howler.js — Modern Web Audio Javascript Library

A tool for audio playback with extended capabilities, so that we can apply them properly in any project; as well for on-line games programming.

Easy to use:

var sound = new Howl({ urls: ['sound.mp3', 'sound.ogg']}).play();

Project website:



Another interesting solution is:

The Buzz library also offers interesting possibilities for sound control in the browser:

Something else, although advanced

A small solution for sound synthesis (+ PCM encoding):

Good sound, but even better source code (definitely I would recommend to take a look).


At the end — links to additional resources:

– details of the HTML5 audio and video:


HTML5 with its uniform APIs was a true breakthrough in programming web applications. Today we have gathered in one place key information to work with HTML5 Audio; to easily implement sound support in the code of our project.;