The <audio> tag is used to add audio files to the HTML page. Audio tag currently supports MP3, WAV, and Ogg formats.
Example
<audio controls>
<source src="audio.mp3" type="audio/mp3">
<source src="audio.wav" type="audio/wav">
This browser does not support audio tag.
</audio>
Attribute
Attribute | Values | Description |
autoplay | autoplay | Specifies that the audio will start playing as soon as it is ready. |
control | control | Specifies that audio controls should be displayed (such as a play/pause button etc). |
loop | loop | Specifies that the audio should be played repeatedly or not |
muted | muted | Specifies that the audio output should be muted. |
preload | Specifies if and how the author thinks the audio should be loaded when the page loads. | |
src | URL | Specifies the URL of the audio file. |
Things to remember
- Most browsers support MP3 format.
- The text provided in the audio tag will be displayed if the browser does not support audio tag.
Subscribe
Join the newsletter to get the latest updates.