Latest web development tutorials

HTML source src attribute

Tag Reference HTML source HTML <source> tag

Examples

Audio player with two source files. The browser should choose which file (if both the source file browsers support):

<audio controls>
  <source src="horse.ogg" type="audio/ogg">
  <source src="horse.mp3" type="audio/mpeg">
您的浏览器不支持 audio 元素。
</audio>

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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

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


Definition and Usage

URL The src attribute specifies the media files to be played.


Differences between HTML 4.01 and HTML5

<Source> tag is new in HTML5 tags.


grammar

<source src="URL">

Property Value

描述
URL 规定媒体文件的 URL。

可能的值:

  • 绝对 URL - 指向另一个网站(比如 href="http://www.example.com/horse.ogg")
  • 相对 URL - 指向网站内的一个文件(比如 href="horse.ogg")


Tag Reference HTML source HTML <source> tag