There is no tag available in HTML previous version to add audio in the Webpage. The majority of audio available on Web pages using the flash plug-in which is also not supported by every browser. HTML introduce a new element <audio> to show audio on webpage without need of any plug-in.
Files format supported by <audio> in HTML 5
Following are the formats supported by the HTML 5 audio element are MP3, Wav and Ogg Voribs
In HTML 5 its very easy to show the audio on Web pages, the only thing you need to do is:
<audio src=”audio file name” > </audio>
Multiple sources can be define in <audio> element. The browser will start running the first recognized format if no format is supported then the message will be displayed on browser.
<audio width="500" height="500"> <source src="music.ogg" type="audio/ogg" /> <source src="music.mp3" type="audio/mp4" />This browser not support audio tag </audio>
Attributes of <Video> in HTML 5
There are number of attributes which can be used in audio element such as:
<audio src=”abc.mp3” controls=”controls”> </audio>
To add play, pause and volume controls in the audio through which you have control over the audio.
<audio src=”abc.mp3” autoplay=”autoplay”><audio>
The audio will play automatically as soon as the page is completely loaded.
<audio src=”abc.mp3” loop=”loop”><audio>
The audio will start running automatically for the start as soon as it finished
<audio src=”abc.mp3” preload=”preload”><audio>
Audio is loaded with the page load, the attribute will be ignored if autoplay attribute is present.