HTML5 Audio Tag

HTML5 is the evolution of web with audio support on different browsers.

  • <audio> tag is one of the success of HTML5 in the media field.
  • <audio> tag is the standard form of playing sound on the web after using flash.
  • <audio> tag embed an audio file on the web.
  • <audio> tag view is different on different browsers.
  • You need to set the source of sound file as a attribute of <audio>tag.
Syntax :
<audio controls preload="none">
<source src="./../media/sound.mp3" type="audio/mpeg">
<source src="./../media/sound.ogg" type="audio/ogg">
<source src="./../media/sound.wav" type="audio/wav">
Output :

Supported audio format in different Browsers

Browser .mp3 .ogg .wav
Google Chrome
Mozilla Firefox
Apple Safari
Internet Explorer

Attribute used in <audio> tag

  1. autoplay : autoplay used to play the audio files on the time of web page loading.
  2. autobuffer : autobuffer used to stream the audio on the time of loading.
  3. controls :controls used to give functionality of play back, play/pause and volume up/down.
  4. loop :loop used to repeat that audio file many times.
  5. preload : preload used to load the audio file same as autoplay.
  6. src : src used to give the source path of audio file.

View of <audio> tag in different Browsers

  • In Google Chrome
  • google-chrome

  • In Mozilla Firefox
  • mozilla-firefox

  • In Apple Safari
  • apple-safari

  • In Opera
  • opera

  • In Internet Explorer
  • iexplorer