Source src Property

❮ Source Object

Example

Return the URL of a media file:

var x = document.getElementById("mySource").src;
Try it Yourself »

Description

The src property sets or returns the value of the src attribute in a <source> element.

The src attribute specifies the URL of the media file to play.


Browser Support

Property
src Yes Yes Yes Yes Yes

Syntax

Return the src property:

sourceObject.src

Set the src property:

sourceObject.src = URL

Property Values

Value Description
URL Specifies the URL of the media file.

Possible values:

  • An absolute URL - points to another web site (like href="http://www.example.com/horse.mp3")
  • A relative URL - points to a file within a web site (like href="horse.mp3")

Technical Details

Return Value: A String, representing the URL of the media file. Returns the entire URL, including the protocol (like http://)

Related Pages

HTML reference: HTML <source> src attribute


❮ Source Object
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.