English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag大全

HTML source src attribute

The src attribute specifies the URL of the media file to be played, this attribute is required when using <source> in <audio> and <video>.

 HTML <source> tag

Online Example

An audio player with two source files. The browser should choose to support the following files (if available):

<audio controls>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
Test to see ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

Internet Explorer 9+、Firefox、Opera、Chrome and Safari support the src attribute.

Note:Internet Explorer 8 and earlier versions do not support the <source> tag.

Definition and Usage

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

This attribute is required when using <source> in <audio> and <video>.

HTML 4.01 with HTML5differences

<source> tag is an HTML5 new tag.

Syntax

<source src="URL">

Attribute value

ValueDescription
URLSpecifies the URL of the media file.
Possible values:
Absolute URL-Points to another website (for example href =“ http://www.example.com/horse.ogg”)
Relative URL-Points to a file within the website (for example href =“ horse.ogg”)
 HTML <source> tag