The audio
tag, or Embed Audio element, embeds sound content into the document, using one or more src
attributes to define the audio source file. The browser will choose the first source that it supports.
Using the src
attribute in a similar manner as the img
tag, the path to the media file to embed is defined. Additional optional attributes can specify such things as automatically playing and looping the media. Any content inside the audio
tag is displayed as a fallback for lack of browser support.
<audio controls autoplay src="audiofile.mp3">
<p>Your browser does not support audio files.</p>
</audio>
autoplay
If included, the audio will immediately begin playing as soon as enough of the file is loaded. This is a Boolean value.
controls
When present, the browser renders controls for audio playback, such as volume, pause/resume, etc.
controlslist
When specified, determines what is shown when the controls
attribute is present. Allowed values are nodownload
, nofullscreen
, and noremoteplayback
.
loop
When specified, the audio will replay from the beginning every time it finishes.
muted
When specified, the audio output will be muted.
preload
This tells the browser how the audio should be loaded when the page loads. Allowed values are auto
, metadata
, and none
.
User-submitted codepen.io examples of <audio>
↴
Submit a codepen.io link that demonstrates <audio>
: