HTML source tag

<source> tag in HTML

The <source> tag allows authors to provide different versions of a file in media elements (audio and video) and pictures.

A media element or picture can contain one or more source elements, each of which provides a different version of the media or picture.

<source> tag should be given under the following elements only.

  • <audio> tag
  • <video> tag
  • <picture> tag

Example 1 - in <picture> tag

Try Yourself

In the below two examples we have given three files in different formats with same content, the browser checks the file format in order and execute the corresponding file.

Example 2 - in <audio> tag

Try Yourself

Example 3 - in <video> tag

Try Yourself