YouTip LogoYouTip

Prop Source Src

# Source src Property [![Image 8: Source Object Reference](#) Source Object](#) ## Example Return the URL of a media file: var x = document.getElementById("mySource").src; The _x_ output could be: [Try it Yourself Β»](#) * * * ## Definition and Usage The src property sets or returns the value of the src attribute of a element. The src property specifies the URL of the media file to be played. **Note:** The element is new in HTML5. **Note:** Internet Explorer 8 and earlier versions only return the file name (e.g., horse.mp3), not the full URL (e.g., http://www.w3cschool.cc/jsref/horse.mp3). * * * ## Browser Support ![Image 9: Internet Explorer](#)![Image 10: Firefox](#)![Image 11: Opera](#)![Image 12: Google Chrome](#)![Image 13: Safari](#) The src property is supported by all major browsers. * * * ## 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 website (e.g., href="http://www.example.com/horse.mp3") * A relative URL - points to a file within a website (e.g., href="horse.mp3") | ## Technical Details | Return value: | A String, representing the URL of the media file. Returns the full URL, including the protocol (e.g., http://). | | --- | * * * ## Related Articles HTML Reference: (#) * * Source Object](#)
← Prop Source TypeProp Source Media β†’