Audio

The new element named <audio> is introduced to play audio files on your webpages.

Before HTML5, to display audio and video files you have to use a plugin like Flash.But with HTML5,you just need to specify the location of  files .

<audio>This is the tag which is  used to embed audio files in your webpage. It has both open and close tag.

Audio Format: wav , mp3 and ogg are commonly used audio formats.

Below is a simple example of audio tag.

<!DOCTYPE html>
 <html>
  <head>
   <title>Audio Example</title>
  </head>
  <body>
         <audio src="audio1.mp3" controls>
          Your browser does not support the audio element.   
         </audio>
  </body>
</html>

Attributes

controls:

Specifies that video controls such as play, pause, volume etc.

loop(A Boolean attribute):

If specified, the audio player will automatically seek back to the start upon reaching the end of the audio.

muted(A Boolean attribute):

This indicates whether the audio will be initially silenced. Its default value isfalse.

src:

The source of file

autoplay(A Boolean attribute):

If this specified, the audio will automatically begin playback as soon as page load, without waiting for the entire audio file to finish downloading.

fallback comment:

The content inside <audio></audio> known as fallback comment, if browser doesn’t support the file included that comment will display.