HTML <source> srcAttribute

HTML source 标签参考手册HTML <source> Tag

Example

An audio player with two source files. The browser should choose which file (if both source files are supported by the browser):

<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>

Try it Yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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.


Differences between HTML 4.01 and HTML5

The <source> tag is new in HTML5.


Syntax

<source src="URL.html">

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.ogg")
  • Relative URL - Points to a file within the website (e.g. href="horse.ogg.html")


HTML source 标签参考手册HTML <source> Tag Other Extensions