Audio

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.

List of attributes of <audio>

  • autoplay - Specifies whether the audio will play automatically or not.
  • autobuffer - Specifies whether the audio will automatically begin buffering even if it's not set to automatically play.
  • controls - Specifies audio including volume, seeking, and pause/resume control options.
  • loop - Specifies whether the audio start after reaching at the end in loop.
  • preload - Specifies that the audio will be loaded at page load, and ready to run.
  • src - Specifies URL of the audio.