HTML <audio> Tag


The Audio element is used to incorporate sound material, such as music or other audio streams, in a document.

The <audio> element contains one or more <source> tags, each of which has a separate audio source. You may use the <source> element to offer other audio files from which the browser can pick. The browser will use the first format that it recognize.

Only browsers that do not support the <audio> element will see the text between the <audio> and </audio> tags.

The controls property includes audio controls such as play, pause, and volume, as well as compatibility for audio formats such as MP3, WAV, and OGG.

Syntax

Example

Preview

Browser MP3 WAV OGG
Chrome YES YES YES
Firefox YES YES YES
Safari YES YES NO
Edge / IE YES YES* YES*
Opera YES YES YES

Attributes

Attribute Value Description
autoplay autoplay The autoplay setting specifies that the audio will begin playing as soon as it is available.
controls controls Specifies whether or not audio controls (such as a play/pause button) should be shown.
loop loop Specifies that the audio shall be restarted whenever it is ended.
muted muted Specifies whether or not the audio output should be muted.
preload auto   
metadata   
none
Specifies whether or not the author believes the audio should be loaded when the page loads.
src URL Specifies the audio file's URL.

Supported Browsers

Element Chrome Firefox Safari Edge / IE Opera
<audio> 4.0 3.5 4.0 9.0 11.5