Latest web development tutorials
 

HTML <source> Tag


Example

An audio player with two source files. The browser should choose which file (if any) it has support for:

<audio controls>
  <source src="horse.ogg" type="audio/ogg">
  <source src="horse.mp3" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>
Try it Yourself »

Definition and Usage

The <source> tag is used to specify multiple media resources for media elements, such as <video> and <audio>.

The <source> tag allows you to specify alternative video/audio files which the browser may choose from, based on its media type or codec support.


Browser Support

The numbers in the table specify the first browser version that fully supports the element.

Element
<source> 4.0 9.0 3.5 4.0 10.5

Differences Between HTML 4.01 and HTML5

The <source> tag is new in HTML5.


Attributes

= New in HTML5.

Attribute Value Description
media media_query Specifies the type of media resource
src URL Specifies the URL of the media file
type media_type Specifies the media type of the media resource

Global Attributes

The <source> tag also supports the Global Attributes in HTML.


Event Attributes

The <source> tag also supports the Event Attributes in HTML.


Related Pages

HTML tutorial: HTML5 Video

HTML tutorial: HTML5 Audio

HTML DOM reference: Source Object


Default CSS Settings

None.