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

HTML Reference Manual

HTML Tag List

HTML: <source> tag

The HTML <source> element specifies multiple media resources for the <picture>, <audio>, or <video> elements. It is an empty element. It is usually used to provide the same media content in multiple formats supported by different browsers.

Online Example

A video player with three source files. The browser needs to select the source file it supports (if all are supported, any can be chosen):

!doctype html
<html>
<head>
<meta charset="UTF-8">
<title>HTML source tag usage (Basic Tutorial Website oldtoolbag.com)</title>
</head>
<body>
<video controls>
  <source src="movie.webm" type="video/webm">
  <source src="movie.ogg" type="video/ogg"> 
  <source src="movie.mov" type="video/quicktime">
  I'm sorry; your browser doesn't support HTML5 video.
</video>
</body>
</html>
Test and see ‹/›

Browser compatibility

IEFirefoxOperaChromeSafari

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

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

Definition and usage description of the tag

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

<source> tag allows you to specify two videos/Audio files let the browser choose based on its support for media types or codecs.

HTML 4.01 and HTML5differences between

<source> tag is in HTML5 New tag in

Attribute

New: HTML5 New attribute in

AttributeValueDescription
mediaHTML5media_querySpecifies the type of the media resource, for the browser to decide whether to download.
srcHTML5URLSpecifies the URL of the media file.
typeHTML5MIME_typeSpecifies the MIME type of the media resource.

Global attributes

Support for <source> tag Global attributes of HTML.

Event attributes

Support for <source> tag HTML event attributes.