HTML5 Audio

By | January 29, 2020

In this we will have to know if we want to add an audio document in our web page, then how to add the audio, there is a poison tag in the HTML5. Earlier it was not easy to add audio to the web page but HTML5 has given the facility to do audio.

Audio Element runs in all modern browser even after being new to HTML5.

Example:-


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

Controls in the given example control audio controls such as play pause volume etc. Source is kept the path of the audio file.

The content between the <audio> and </audio> tags will only be displayed in browsers that do not enable the audio element. In the given example, “ogg” track opera works in Firefox Chrome while “mp3” formats are added to work in Safari Internet Explorer.

Audio Browser Support

BrowserWAVMP3OGG
Edge/IENo YesNo
ChromeYes Yes Yes
Firefox Yes Yes Yes
Safari Yes YesNo
Opera Yes Yes Yes

Audio Files Linking

You can make links to your audio files and when we click on them the audio will start something like this.

<a href="audio/track1.mp3">Track First</a>
<a href="audio/track2.mp3">Track Second</a>
Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *