Get Website Learn Coding Tech Story

HTML5 Examples

Audio element is the one of the best powerful weapons of Html5. Before the audio elements of Html5, we were unable to play an audio file without using the third party browsers plug-in as flash player or Quicktime. Now, it support full user control for playing the audio file in the browser without installing a browser plug-in.

Html5 supports <audio> tag which is used to embed sound content in an HTML or XHTML document. The current Html5 does not specify which audio formats browsers should support in the audio tag. But most commonly used audio formats are ogg, mp3 and wav. <source> tag use to specify media along with media type. An audio element allows multiple source elements and browser will use the first recognized format.

Attribute Description
autoplaySpecifies whether the audio will play automatically or not.
autobufferSpecifies whether the audio will automatically begin buffering even if it's not set to automatically play.
controlsSpecifies audio including volume, seeking, and pause/resume control options.
loopSpecifies whether the audio start after reaching at the end in loop.
preloadSpecifies that the audio will be loaded at page load, and ready to run.
srcSpecifies URL of the audio.
<audio controls autoplay>
	<source src="music.mp3" type="audio/mpeg" />
	<source src="music.ogg" type="audio/ogg" />
	<source src="music.wav" type="audio/wav" />
	Your browser does not support the <audio> element.