HTML <source> src Attribute

Definition and Usage

src The attribute specifies the URL of the media file to be played.

When <source> is used <audio> and <video> This attribute is required when

Example

This is an audio player with two audio source files. The browser should choose the file it supports (if any):

<audio controls>
  <source src="song.ogg" type="audio/ogg">
  <source src="song.mp3" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>

Try It Yourself

Syntax

<source src="URL">

Attribute Value

Value Description
URL

Specifies the URL of the media file.

Possible values:

  • Absolute URL - Points to another website (e.g., href="http://www.example.com/horse.ogg")
  • Relative URL - Points to a file within the website (e.g., href="horse.ogg")

Browser Support

The numbers in the table indicate the first browser version to fully support this attribute.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
4.0 9.0 3.5 4.0 10.5