HTML <audio> src attribute
Definition and usage
src
Attribute specifies the location of the audio file (URL).
Tip:can also be used <source> tag to set the audio.
Instance
Example 1
Play sound:
<audio src="song.mp3" controls> Your browser does not support the audio tag. </audio>
Example 2
To make it work in all browsers - please use the <audio> element <source> element.
Each <source> element can link to different audio files. The browser will use the first recognized format:
<audio controls> <source src="song.ogg" type="audio/ogg"> <source src="song.mp3" type="audio/mpeg"> Your browser does not support the audio tag. </audio>
Syntax
<audio src="URL">
Attribute Value
Value | Description |
---|---|
URL |
URL of the audio file. Possible values:
|
Browser Support
The numbers in the table indicate the first browser version that fully supports this attribute.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
4.0 | 9.0 | 3.5 | 4.0 | 11.5 |
Note:All mainstream browsers support the src attribute, but the file format may not be supported by all browsers!