Easy Tutorial
❮ Jsref Regexp Whitespace Jsref Regexp Nxy ❯

Source src Attribute

Source Object

Example

Return the URL of the media file:

x Output result:


Definition and Usage

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

The src attribute specifies the URL of the media file to be played.

Note: The <source> element is new in HTML5.

Note: Internet Explorer 8 and earlier versions only return the file name (e.g., horse.mp3) instead of the URL (e.g., http://www.w3cschool.cc/jsref/horse.mp3).


Browser Support

All major browsers support the src attribute.


Syntax

Return the src attribute:

Set the src attribute:

Attribute Values

Value Description
URL Specifies the URL of the media file. Possible values: Absolute URL - points to another website (e.g., href="http://www.example.com/horse.mp3")<br>Relative URL - points to a file within the website (e.g., href="horse.mp3")

Technical Details

| Return Value: | String, representing the URL of the media file. Returns the full URL, including the protocol (e.g., http://). | | --- | --- |


Related Articles

HTML Reference: HTML <source> src Attribute


Source Object

❮ Jsref Regexp Whitespace Jsref Regexp Nxy ❯