<audio controls>
<source src="audio.mp3" type="audio/mp3">
Your browser does not support the audio tag.
// this text display when your do't support audio tag
</audio>
Example
| Attribute/tag | Details |
|---|---|
| <source> | Defines resources of the audio or video files |
| controls | Displays controls |
| autoplay | Automatically start playing the media when page load |
| loop | Plays the media in a repeated cycle |
| muted | Plays the media without sound |
Use the HTML or <audio> element to embed video/audio content in a document. The video/audio element contains one or more video/audio sources. To specify a source, use either the src attribute or the <source> element; the browser will choose the most suitable one.
<audio src="audio.mp3" controls>
Sorry, your browser doesn't support embedded audios,
but don't worry, you can
<a href="audio.mp3">download it</a>
and watch it with your favorite audio player!
</audio>
The <source> tag allows you to specify multiple audio format for the browser to choose from. The browser uses the first recognized format.
<audio width="480" controls>
<source src="audio.mp3" type="audio/mp3">
<source src="audio.ogg" type="audio/ogg">
<source src="audio.wav" type="audio/wav">
Your browser doesn't support HTML5 audio tag.
</audio>
The Controls attribute to display audio controls, like play, pause, and volume.
<audio width="450" controls>
<source src="audio.mp3" type="audio/mp3">
Your browser does not support the audio tag.
</audio>
A Boolean attribute; if specified, the audio automatically begins to play back as soon as it can do so without stopping to finish loading the data. Automatically start playing the media when page load.
An audio file that will automatically start playing:
<audio width="450" autoplay>
<source src="audio.mp3" type="audio/mp3">
Your browser does not support the audio tag.
</audio>
A Boolean attribute; if specified, the browser will automatically seek back to the start upon reaching the end of the media.
Plays the media in a repeated cycle(loop)
<audio width="450" loop>
<source src="audio.mp3" type="audio/mp3">
Your browser does not support the audio tag.
</audio>
A Boolean attribute that indicates whether the audio will be initially silenced. Its default value is false.
Plays the media without sound
<audio width="450" muted>
<source src="audio.mp3" type="audio/mp3">
Your browser does not support the audio tag.
</audio>
Share TDB SCHOOL
Share this E-Learning Website on social media platforms with your friends and followers