<source>


HTML <source> Tag

Instance

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>php中文网(php.cn)</title> 
</head>
<body>

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

</body>
</html>

Run Example»

Click the "Run Instance" button to view the online instance


Browser support

1000.png

IE 9+, Firefox, Opera, Both Chrome and Safari support the <source> tag.

Note: IE 8 or earlier versions of IE browsers do not support the <source> tag.


Tag definition and usage instructions

<source> tag defines media resources for media elements (such as <video> and <audio>). The

<source> tag allows you to specify two video/audio files that the browser selects based on its media type or codec support.


Differences between HTML 4.01 and HTML5

The<source> tag is a new tag in HTML5.


Attributes

New: New attributes in HTML5.

PropertiesValueDescription
mediaNew media_querySpecifies the type of media resource for the browser to decide whether to download.
srcNewURLSpecifies the URL of the media file.
typeNewMIME_typeSpecifies the MIME type of the media resource.

Global attributes

<source> tag supports HTML global attributes.


Event attributes

<source> tag supports HTML event attributes.