Audio src attribute

Definition and usage

src attribute sets or returns the audio The <audio> src attribute value.

src The attribute specifies the location (URL) of the audio file.

Example

Get the URL of the audio file:

var x = document.getElementById("myAudio").src;

Try it yourself

Syntax

Return the src attribute:

audioObject.src

Set the src attribute:

audioObject.src = URL

Attribute value

Value Description
URL

Specifies the URL of the audio file.

Possible values:

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

Technical Details

Return Value: A string value representing the URL of the audio file. Returns the entire URL, including the protocol (such as http://).

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support

All mainstream browsers support the src attribute. However, not all browsers support the defined file formats.

Related Pages

HTML Reference Manual:HTML <audio> src Attribute