HTML <source> Tag

Description

The <source> HTML element is used to specify multiple media resources on media elements (such as <audio> and <video>).
This element allows you to specify alternative video and audio files which the browser may choose from based on its media type or codec support.

Properties

Permitted Parents
A media element—<audio> or <video>—and it must be placed before any flow content or <track> element. A <picture> element, and it must be placed before the <img> element
Content
None. It is an empty element.
Start/End Tags
Start tag: required, End tag: forbidden

Example

<video width="300" height="240" controls>
<source src="audio/toy.mp4" type="video/mp4">
<source src="audio/toy.ogv" type="video/ogg">
Your browser does not support the video tag.
</video>

Attributes

Attribute Definition
src Specifies the URL of the media file
media Specifies the type of media resource
type Specifies the MIME type of the media resource

Global Attributes

The <source> tag also supports the Global Attributes in HTML5

Event Attributes

The <source> tag also supports the Event Attributes in HTML5

Browser Support

Desktop
Explorer Edge Chrome Firefox Opera Safari
9YesYes3.5YesYes
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
YesYes4XYesYes