Dofactory.com
Dofactory.com
Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

HTML <source> src Attribute

The src attribute on a <source> tag specifies the URL or path of a resource file.

This URL points to the media file to display or play.

Example

#

A src attribute on two <source> elements.
Each source has a src attribute referencing different audio files.

<audio controls>
  <source src="/media/epic.mp3" type="audio/mpeg">
  <source src="/media/epic.wav" type="audio/wav">
</audio>

Using src

The src attribute specifies the URL or path of the resource file.

The URL points to the media file to display (images) or play (audio and video).

The browser uses the URL to locate and load the media file.

The URL can be internal (from same website) or external (another website).


Syntax

<source src="URL" />

Values

#

Value Description
URL URL or path of the resource file

More Examples

A video element with different file sources.

<video width="320" height="240" controls>
  <source src="/media/movie.mp4" type="video/mp4">
  <source src="/media/movie.ogg" type="video/ogg">
</video>

Browser support

Here is when src support started for each browser:

Chrome
4.0 Jan 2010
Firefox
3.5 Jun 2009
IE/Edge
9.0 Mar 2011
Opera
10.5 Mar 2010
Safari
4.0 Jun 2009

You may also like

 Back to <source>

Last updated on Sep 30, 2023

Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

Guides