Video src attribute

Definition and usage

src The attribute sets or returns the value of the video's src attribute.

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

Example

Example 1

Change the video URL:

document.getElementById("myVideo").src = "beijing.mp4";

Try it yourself

Example 2

Get the video URL:

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

Try it yourself

Syntax

Return the src attribute:

videoObject.src

Set the src attribute:

videoObject.src = URL

Attribute value

Value Description
URL

Specifies the URL of the video file.

Possible values:

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

Technical Details

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

Browser Support

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

Related Pages

HTML Reference Manual:HTML <video> src Attribute