HTML <source> Tag

If this site has been useful, we’d love your support! Running this site takes time and resources, and every small contribution helps us keep creating valuable content. Consider buying us a coffee to keep things going strong!

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

The following table will show you the current browser support for the HTML <source> tag.

Desktop
Edge Chrome Firefox Opera Safari
1233.5153.1
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview
18414214.4

Last updated by CSSPortal on: 30th March 2024