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>

Try It Yourself

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>

Try It Yourself

Syntax

<audio src="URL">

Attribute Value

Value Description
URL

URL of the audio file.

Possible values:

  • Absolute URL - Points to another website (e.g., src="http://www.example.com/song.mp3")
  • Relative URL - Points to a file within the website (e.g., src="song.mp3")

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!