HTML <source> src egenskab

Definition og brug

src egenskab definerer URL'en til det medie, der skal afspilles.

når <source> bruges til <audio> og <video> the attribute is required.

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