Hurry! Try our new Interactive Courses for FREE. 🥳   🚀
  Signup/Sign In

HTML Source Tag

In HTML, the <source> tag is used to represent multiple media resources for a picture, an audio or video in a document.

  • <source> tag is an Empty element.

  • The <source> tag is used to serve the same media content in multiple formats which then further supported by different browsers.

HTML <source> Tag Syntax and Usage

The <source> tag requires the start(opening) tag only; it does not require an end tag because it is an empty element.

Given below is the basic syntax:

<source src=" ">

HTML <source> Tag Attributes

The <source> tag supports both global and event attributes and some of the common attributes are given below.

Attributes Description
src This attribute specifies the required resource of audio and video in the form of a URL
media It is used only for picture elements.
sizes This attribute specifies a list of source sizes that is used to describes the final rendered width of the image as represented by the source
srcset This attribute is used to specify the URL of an image in different situations
type This attribute is used to specify the MIME type of the resource.

HTML <source> Tag Basic Example

Given below is the basic example of <source> tag:

<video controls>
  <source src="abc.webm" type="video/webm">
  <source src="abc.ogg" type="video/ogg"> 
  <source src="abc.mov" type="video/quicktime">
  I'm sorry; your browser doesn't support HTML5 video.
</video>

Browser Support for HTML <source> Tag

Following browsers support this attribute:

  • Firefox 3.5+

  • Google Chrome 4+

  • Internet Explorer 9+

  • Safari 4+

  • Opera 10.5+