HTML5 Audio element

HTML5-logoHTML5 has an “audio” element. You can play directly audio content in your web page. I’ve sample code for you below.

Sample code for HTML5 Audio element :

<audio controls=”controls”>

<source src=”audiofile.ogg” type=”audio/ogg” />

<source src=”audiofile.mp3″ type=”audio/mp3″ />

Your browser does not support the audio tag. View in a different browser.


Attributes for audio element :

controls : adds controls to your audio element such as play, volume and pause.

type : specifies type of format for the audio file.

src : source or location of your audio file.

Audio element supports multiple source file for your audio. Note that different browsers support different format for both Audio and Video file formats.

Click here to find out files and format supported by various browsers.

Hope this is helpful. Please write your feedback or comments below if you have any questions. We will get back to you!