HTML audio tag

<audio> tag in HTML

The <audio> tag is used to play supported audio files.

Chrome,firefox and opera browsers support .mp3,.wav and .ogg audio files.

Internet Explorer only support .mp3 files.

Safari browser doesn't support .ogg files.

MIME-Type

  • .mp3 - audio/mpeg
  • .wav - audio/wav
  • .ogg - audio/ogg

autoplay and src attribute in <audio> tag

src attribute is used to give path of the audio file.

If you add autoplay attribute with the <audio> tag, the given audio file will play automatically when the web page finished loading.

Example

Try Yourself

controls attribute in <audio> tag

The controls attribute is used to show audio player controls like play, sound buttons.

Example

Try Yourself

muted attribute in <audio> tag

The muted attribute is used to mute the sound control.

Example

Try Yourself

loop attribute in <audio> tag

The loop attribute is used to play the given audio file repeatedly.

Example

Try Yourself