Learn one of the most powerful programming languages in the world and become a rockstar developer.
Before HTML5, audio files could only be played in a browser with a plug-in (like flash).
<audio> element specifies a standard way to embed audio in a web page.
The numbers in the table specify the first browser version that fully supports the
To play an audio file in HTML, use the
<audio controls="controls" src="media/birds.mp3"> Your browser does not support the HTML5 Audio element. </audio>
An audio, using the browser default set of controls, with alternative sources.
<audio controls="controls"> <source src="media/birds.mp3" type="audio/mpeg"> <source src="media/birds.ogg" type="audio/ogg"> Your browser does not support the HTML5 Audio element. </audio>
In HTML5, there are 3 supported audio formats: MP3, WAV, and OGG.
The browser support for the different formats is:
|File Format||Media Type|
HTML5 defines DOM methods, properties, and events for the
This allows you to load, play, and pause audios, as well as set duration and volume.
There are also DOM events that can notify you when an audio begins to play, is paused, etc.