<source> tag

HTML5 <source> tag

The <source> tag specifies multimedia resources for <audio> and <video> elements. Browser selects the source based on Media type, Media query and Codec support.

<source src=”audiofilename.mp3″ type=”type=”audio/audio-file-type”>
<source src=”videfilename.mp4″ type=”type=”video/video-file-type“>
<source media=”width=value” srcset=”type=”image_url”>


<audio controls autoplay>
  <source src="html-audio.mp3" type="audio/mpeg">
  Your browser does not support the HTML audio tag.

How Browser will display


Difference between HTML4.01, XHTML and HTML5

NA NA New tag in HTML5

Attributes used with <source> tag

Attribute Description
media Defines the type of media file for which media query is applied. This attribute can also accept several values.
sizes Sets the Image size.
src Defines the address of the source for audio or vido files.
srcset Sets the URL of the image when it is inside the <picture> tag.
type Media type of the media resource

Global Attributes

The <source> tag supports Global attributes.

Event Attributes

The <source> tag supports Event attributes.

Supporting Browsers

supporting-browsers for tags

Related Tags

<picture>, <img>, <video>  & <audio> tags.

Tutorials for all brains!