The HTML <audio> Element
To play an audio file in HTML, use 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 attribute adds audio controls, like play, pause, and volume.
The <source> element allows you to specify alternative audio files which the browser may choose from. The browser will use the first recognized format.
The text between the <audio> and </audio> tags will only be displayed in browsers that do not support the <audio> element.
HTML Audio Formats
There are three supported audio formats: MP3, WAV, and OGG. The browser support for the different formats is:
HTML Audio - Media Types
HTML Audio - Methods, Properties, and Events
The HTML DOM defines methods, properties, and events for the <audio> element.
This allows you to load, play, and pause audios, as well as set duration and volume.
There are also DOM events that can notify you when an audio begins to play, is paused, etc.
HTML Audio Tags
![51.PNG](https://static.wixstatic.com/media/0aad0d_4f23a8e1ce16459ba034c46be6672729~mv2.png/v1/fill/w_707,h_180,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/51_PNG.png)
![52.PNG](https://static.wixstatic.com/media/0aad0d_7da017e5aff24642bd5366126de2ef40~mv2.png/v1/fill/w_725,h_124,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/52_PNG.png)
![53.PNG](https://static.wixstatic.com/media/0aad0d_8e28b6e133b6459096d1f9f4c28b43a6~mv2.png/v1/fill/w_761,h_98,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/53_PNG.png)