HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
Play a sound file
The <audio>
tag is used to embed sound
content in a document, such as music or other audio streams.
The <audio>
tag contains one or more
<source>
tags
with different audio sources. The browser will choose the first source it
supports.
The text between the <audio>
and </audio>
tags will only be displayed in browsers that do not support the <audio>
element.
There are three supported audio formats in HTML: MP3, WAV, and OGG.
Audio Format and Browser Support
Browser | MP3 | WAV | OGG |
---|---|---|---|
Edge / IE | YES | YES* | YES* |
Chrome | YES | YES | YES |
Firefox | YES | YES | YES |
Safari | YES | YES | NO |
Opera | YES | YES | YES |
*From Edge 79
<video>
tag.
The numbers in the table specify the first browser version that fully supports the element.
Element | |||||
---|---|---|---|---|---|
<audio> | 4.0 | 9.0 | 3.5 | 4.0 | 11.5 |
Attribute | Value | Description |
---|---|---|
autoplay | autoplay | Specifies that the audio will start playing as soon as it is ready |
controls | controls | Specifies that audio controls should be displayed (such as a play/pause button etc) |
loop | loop | Specifies that the audio will start over again, every time it is finished |
muted | muted | Specifies that the audio output should be muted |
preload | auto metadata none |
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 |
The <audio>
tag also supports the Global Attributes in HTML.
The <audio>
tag also supports the Event Attributes in HTML.
HTML DOM reference: HTML Audio/Video DOM Reference
None.