HTML <audio> -tag
Voorbeeld
Een geluidsbestand afspelen:
<audio controls>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio tag.
</audio>
Definitie en gebruik
De <audio>
tag wordt gebruikt om geluidsinhoud in een document in te sluiten, zoals muziek of andere audiostreams.
De <audio>
tag bevat een of meer
<source>
tags met verschillende audiobronnen. De browser kiest de eerste bron die het ondersteunt.
De tekst tussen de <audio>
en tags wordt alleen weergegeven in browsers die het element </audio>
niet ondersteunen .<audio>
Er zijn drie ondersteunde audioformaten in HTML: MP3, WAV en OGG.
Audioformaat en browserondersteuning
Browser | MP3 | WAV | OGG |
---|---|---|---|
Edge / IE | YES | YES* | YES* |
Chrome | YES | YES | YES |
Firefox | YES | YES | YES |
Safari | YES | YES | NO |
Opera | YES | YES | YES |
*Vanaf rand 79
Tips en opmerkingen
Tip: Kijk voor videobestanden naar de tag.
<video>
Browserondersteuning
De getallen in de tabel geven de eerste browserversie aan die het element volledig ondersteunt.
Element | |||||
---|---|---|---|---|---|
<audio> | 4.0 | 9.0 | 3.5 | 4.0 | 11.5 |
attributen
Attribute | Value | Description |
---|---|---|
autoplay | autoplay | Specifies that the audio will start playing as soon as it is ready |
controls | controls | Specifies that audio controls should be displayed (such as a play/pause button etc) |
loop | loop | Specifies that the audio will start over again, every time it is finished |
muted | muted | Specifies that the audio output should be muted |
preload | auto metadata none |
Specifies if and how the author thinks the audio should be loaded when the page loads |
src | URL | Specifies the URL of the audio file |
Algemene kenmerken
De <audio>
tag ondersteunt ook de Global Attributes in HTML .
Gebeurteniskenmerken
De <audio>
tag ondersteunt ook de Event Attributes in HTML .
Gerelateerde pagina's
HTML DOM-referentie: HTML Audio/Video DOM-referentie
Standaard CSS-instellingen
Geen.