HTML <audio> -Tag


Beispiel

Sounddatei abspielen:

<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>

Definition und Verwendung

Das <audio>Tag wird verwendet, um Soundinhalte in ein Dokument einzubetten, wie z. B. Musik oder andere Audiostreams.

Das <audio>Tag enthält ein oder mehrere <source>Tags mit unterschiedlichen Audioquellen. Der Browser wählt die erste Quelle, die er unterstützt.

Der Text zwischen den Tags <audio>und wird nur in Browsern angezeigt, die das Element </audio> nicht unterstützen .<audio>

Es gibt drei unterstützte Audioformate in HTML: MP3, WAV und OGG.

Audioformat und Browserunterstützung

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

*Ab Edge 79


Tipps und Hinweise

Tipp: Sehen Sie sich bei Videodateien das Tag an. <video>



Browser-Unterstützung

Die Zahlen in der Tabelle geben die erste Browserversion an, die das Element vollständig unterstützt.

Element
<audio> 4.0 9.0 3.5 4.0 11.5

Attribute

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

Globale Attribute

Das <audio>Tag unterstützt auch die globalen Attribute in HTML .


Ereignisattribute

Das <audio>Tag unterstützt auch die Ereignisattribute in HTML .


Verwandte Seiten

HTML-DOM-Referenz: HTML-Audio/Video-DOM-Referenz


Standard-CSS-Einstellungen

Keiner.