There is a tag to add audio files on a webpage and play it. <audio> tag is used to add audio files to web pages.
<audio controls>
<source src="FileName" type="audio/ogg">
<source src="FileName" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
In the code above there is a controls attribute that is used to add controls to the audio player.
The source element tag is used to add the source audio file in the src attribute and its type is mentioned in the type attribute.
If the file is not found then a statement “Your browser does not support the audio element.” is shown.
Autoplay and muted attribute
The autoplay attribute is added for the autoplay of the audio file. When muted attribute is added the audio will be muted.
<audio controls autoplay>
<source src="AudioFileName" type="audio/ogg">
<source src="AudioFileName" type="audio/mpeg">
Your browser does not support the audio element.
</audio>