What is an audio element?

An audio element is the most easiest and reliable way to embed audio files, music, podcasts, sound and sound effects directly into your webpage. Allowing users on your site to play audio content easily without needing extra code, external plugins or software.

Which element do we use to embed sound on a webpage?

We use this element <audio> </audio> to embed sound or audio files on a webpage. But when using this element you must specify the source of the sound or audio file using the src = "your-audio-file.mp3" attribute, and the name between the quotation marks is the name of your audio file you want to play on your webpage. We then use the controls attribute that tells the browser to display controls that control the play button, volume button, pause button and progress bar for the sound or audio file. Without the control attribute we will not be able to control the audio file to play or pause, we will have to use javascipt to control it.


This audio element is also used in Html5 and most popular web browsers support it, making making it the easiest way to embed audio files into a webpage.


Example audio element

<audio src = "audio.mp3" controls></audio>

Why is an audio element important?

It is important because it allows developers to embed audio files on a webpage, without needing external plugins or tools which developers in the past had to rely to play audio files on a site. It also helps improve user engagement and experience, for example educational websites can include voice explanation audio files so that leaners can understand better if they have difficulties reading or understanding the text. Music streaming platforms like spotify also rely on this element to embed music files on their site.

Html quiz

What is the correct syntax for an html h1 element?