Description
HTML element <audio>
can be used to embed audio content into an HTML document.
It can include one or more audio source files using the <source>
element and can include a text that displays when the browser does not support <audio>
element.
The below table summarizes its usage.
Usage Details | |
Placement | It is displayed as a Block element. |
Contents | It can contain the elements <source> , <track> , and text. |
Tags | Both opening and closing tags are required. |
Versions | HTML5 |
Syntax
<audio>...</audio>
Examples
Basic usage for a single audio source.
<audio controls="controls" src="/assets/audios/music.mp3">
Oops!! Your browser does not support audio element.
</audio>
Multiple audio source files.
<audio controls>
<source src="/assets/audios/music.mp3" type="audio/mpeg">
<source src="/assets/audios/music.wav" type="audio/wav">
<source src="/assets/audios/music.ogg" type="audio/ogg">
Oops!! Your browser does not support audio element.
</audio>
Attributes
The following table shows the list of supported and unsupported attributes for the <audio>
tag.
Attribute Type | Details |
Tag-Specific Attributes | The tag <audio> support the below tag-specific attributes. |
Global Attributes | Like all other HTML tags, the tag <audio> supports the HTML Global Attributes. |
Event Attributes | The tag <audio> also supports the HTML Event Attributes. |
Browser Compatibility
The tag <aside>
is supported in all modern browsers.
- Google Chrome 4+
- Internet Explorer or Edge 9+
- Firefox 3.5+
- Apple Safari 4+
- Opera 10.5+