What Is The HTML Audio
The HTML Audio component is utilized to play a sound document on a website page.
The HTML <audio> Element
To play a sound document in HTML, utilize the <audio>
element:
Example
<audio controls>
<source src=”horse.ogg” type=”audio/ogg”>
<source src=”horse.mp3″ type=”audio/mpeg”>
Your browser does not support the audio element.
</audio>
HTML Audio – How It Works
The controls trait adds sound controls, similar to play, interruption, and volume.
The <source>
component permits you to determine elective sound records which the program might look over. The program will utilize the main perceived arrangement.
The content between the <audio>
and </audio>
labels might be shown in programs that don’t uphold the <audio>
element.
HTML <audio> Autoplay
To begin a sound document consequently, utilize the autoplay property:
Example
<audio controls autoplay>
<source src=”horse.ogg” type=”audio/ogg”>
<source src=”horse.mp3″ type=”audio/mpeg”>
Your browser does not support the audio element.
</audio>
Note: Chromium browsers do not allow autoplay in most cases. However, muted autoplay is always allowed.
Add quieted after autoplay to allow your sound to record begin playing naturally (yet quieted):
Example
<audio controls autoplay muted>
<source src=”horse.ogg” type=”audio/ogg”>
<source src=”horse.mp3″ type=”audio/mpeg”>
Your browser does not support the audio element.
</audio>
Browser Support
The numbers in the table determine the main program form that completely upholds the

HTML Audio Formats
There are three upheld sound arrangements: MP3, WAV, and OGG. The program support for the various configurations is:
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 |
HTML Audio – Media Types
File Format | Media Type |
---|---|
MP3 | audio/mpeg |
OGG | audio/ogg |
WAV | audio/wav |
HTML Audio – Methods, Properties, and Events
The HTML DOM characterizes strategies, properties, and occasions for the<audio>
element.
This permits you to load, play, and respite sounds, just as set term and volume.
There are likewise DOM occasions that can inform you when a sound starts to play, is stopped, and so on.
For a full DOM reference, go to our HTML Audio/Video DOM Reference.