Learn audio tags in HTML
The audio tags is used to specify sounds such as music and other audio clips. Currently three file formats for audio tags in HTML5 are supported.
- mp3
- wav
- ogg
HTML5 supports <video> and <audio> controls. Flash, Silverlight and similar technologies are used to play multimedia elements.
The table below specifies which web browser supports which audio file format.
mp3 | wav | ogg | Browser name |
Yes | No | No | Internet Explorer |
Yes | Yes | Yes | Google Chrome |
Yes | Yes | Yes | Mozilla Firefox |
No | Yes | Yes | Opera |
Yes | Yes | No | Apple Safari |
Example for HTML audio tag
In the following code, we see the 3mp file playback using the HTML audio tag.
<audio controls >
<source src = ”koyal.mp3 ″ type =” audio / mpeg ” >
Your browser does not support the html audio tag.
</audio>
Output
In the following code, you can see the ogg file playback using the HTML audio tag.
<audio controls >
<source src = ”koyal.ogg” type = ”audio / ogg” >
Your browser does not support the html audio tag.
</audio>
Backup browsers
Element name | Chrome | IE | Firefox | Opera | Safari |
<audio> | Yes | Yes | Yes | Yes | Yes |
Audio tag features in HTML
The following table lists the features or attributes of the audio tag in HTML.
Description | Feature name |
Defines audio controls that are displayed with the play / stop buttons. | controls |
Specifies that the audio file start playing as soon as it is ready. | autoplay |
Specifies that it resumes playback each time the audio file is finished. | loop |
Used to mute the output sound. | muted |
Specifies the author’s opinion for uploading the audio file when loading the page. | preload |
The URL specifies the source of the audio file. | src |
Example of Audio tag features
Here we use the attributes controls, autoplay, loop and src in the audio tag.
<audio controls autoplay loop >
<source src = ”koyal.mp3 ″ type =” audio / mpeg ” > </audio>
MIME types for audio format in HTML
The available MIME type for the audio tag is given in the table below.
MIME type | Audio format |
audio / mpeg | mp3 |
audio / ogg | ogg |
audio / wav | wav |