HTML Audio/Video DOM src Attribute

Example

Change the video source:

myVid=document.getElementById("video1");
myVid.src="movie.ogg";

Try it Yourself

Definition and Usage

The src attribute sets or returns the current source of the audio/video.

Browser Support

All major browsers support the src attribute, except for Internet Explorer.

Syntax

Set src attribute:

audio|video.src=URL

Return src attribute:

audio|video.src

Attribute value

Value Description
URL

Specifies the URL of the audio/video source.

Possible values:

  • Absolute URL - points to another website (e.g., src="http://example.com/movie.ogg")
  • Relative URL - points to a file within the website (e.g., src="/data/movie.ogg")

Return value

Type Description
String value Current audio/video source.