HTML <audio> src eigenschap

Definitie en gebruik

src De eigenschap bepaalt de locatie van het audiobestand (URL).

Tip:kan ook worden gebruikt <source> tag om audio in te stellen.

Voorbeeld

Voorbeeld 1

Spelen van geluid:

<audio src="song.mp3" controls>
Your browser does not support the audio tag.
</audio>

Try it yourself

Voorbeeld 2

Om ervoor te zorgen dat het in alle browsers werkt - gebruik in het <audio> element: <source> element.

Elke <source> element kan koppelen aan verschillende audiobestanden. De browser zal het eerste herkende formaat gebruiken:

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

Try it yourself

Syntax

<audio src="URL">

Attribute value

Value Description
URL

URL of the audio file.

Possible values:

  • Absolute URL - points to another website (such as src="http://www.example.com/song.mp3")
  • Relative URL - points to a file within the website (such as src="song.mp3")

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 11.5

Note:All mainstream browsers support the src attribute, but the file format may not be supported by all browsers!