In this section, we will learn what src attribute is and how it works.
What is src Attribute in HTML audio Tag?
The HTML <audio> element on its own doesn’t do much if we don’t provide it with an audio file to work with.
We can set an audio file for the HTML <audio> element with the help of the `src` attribute.
Basically, the value of this attribute is the URL address of the target audio file that we want to display on our audio player.
Note: using the src attribute we can only pick one audio format and that might not be supported by all browsers! For these reasons, developers usually use HTML <source> element instead, which allows them to set multiple formats of the same audio file!
HTML src Attribute in audio Tag Syntax:
<audio src = "audio-file-address"> </audio>
audio Tag src Attribute Values
The src attribute takes a string value, which is the URL of the target audio file that we want to be played on the webpage.
Example: using src attribute in HTML audio tag
See the Pen using src attribute in HTML audio tag by Omid Dehghan (@odchan1) on CodePen.