HTML source Tag

HTML <source>Tag: The HTML<source> tag specifies multiple media resources for media elements such as <video>, <audio>, and <picture>. And the HTML  source tag allows you to specify alternative video/audio/image files which the browser may choose from, based on its media type, codec support or media query.

HTML <source>Tag

This HTML source tag supports both the global and the event attributes. HTML5 supports <source> tag.

Syntax: <source>

Browser compatibility

The HTML <source> tag is supported by different types of browsers.

  • Chrome-4.0
  • Firefox-3.5
  • Opera-10.5
  • Safari-4.0
  • Internet Explorer-9.0

Attributes that are supported by the <source> tag

Attribute Value Description
src URL Required when is used in audio and video. Specifies the URL of the media file
srcset URL Required when the source is used in the picture. Specifies the URL of the image to use in different situations picture
media media_query Accepts any valid media query that would normally be defined in a CSS
sizes Specifies image sizes for different page layouts
type MIME-type Specifies the MIME-type of the resource