Audios could previously only be played on websites using web plugins such as Flash. The "audio" tag is an inline element for embedding sound files into a web page. It's a handy tag if you want to include audio on your website, such as songs or interviews.

To play an audio file on the webpage, we can use the < audio> element. The file formats which can be used are MP3, WAV, OGG. The attributes which can be used with the < audio> tag are as follows:

The following are the many properties that can be utilised with the "audio" tag:

  • Controls : Defines which controls should be displayed beside the audio player.
  • Autoplay : Indicates that the audio file will begin playing immediately after the controls have been loaded.
  • Loop : Indicates that the audio file will be repeated indefinitely.
  • src : Indicates the audio file's URL.
  • muted : This specifies that the audio file is muted.
  • controls

    used to add audio controls like play, pause.

  • autoplay

    used to play the audio as soon as it is executed

  • muted

    used to mute the audio

  • loop

    used to play the audio repeatedly

Example No:

<html> <body> <h1>Knowledge2life</h1> <audio controls> <source src="cat.ogg" type="audio/ogg"> <source src="cat.mp3" type="audio/mpeg"> </audio> </body> </html>