<audio preload=""> HTML Attribute
Disclosure: Your support helps keep the site running! We earn a referral fee for some of the services we recommend on this page. Learn more
- Attribute of
- New Audio HTML Element: Master It Out Now With Our Code Example
- What does
<audio preload=""> HTML Attribute
do? - Requests a particular preload behavior to the browser, which the browser may or may not follow.
Contents
Code Example
<h3>Flamingo Sounds</h3>
<audio controls id="audio-example" preload="auto">
<!-- One or more source files, each referencing the same audio but in a different file format.
The browser will choose the first file which it is able to play. -->
<source src="/wp-content/uploads/flamingos.ogg">
<source src="/wp-content/uploads/flamingos.mp3">
You will see this text if native audio playback is not supported.
<!-- You could use this fall-back feature to insert a JavaScript-based audio player. -->
</audio>
<small>Audio by <a href="https://soundcloud.com/beeldengeluid">Beeld en Geluid</a> [<a href="http://creativecommons.org/licenses/by-sa/3.0">CC BY-SA 3.0</a>], <a href="https://commons.wikimedia.org/wiki/File%3AArtis%2C_enkele_flamingo's_-_SoundCloud_-_Beeld_en_Geluid.ogg">via Wikimedia Commons</a></small>
<style>
#audio-example {
display: block;
}
</style>
Values of the preload
Attribute
Value Name | Notes |
---|---|
none | Requests that the browser not preload the audio file. The browser is free to ignore this request. |
metadata | Requests that the browser download the audio file’s metadata immediately on page load. The browser is free to ignore this request. |
auto | Requests that the browser download the entire audio file, regardless of whether the user is expected to play it. The browser is free to ignore this request. |
All Attributes of audio
Element
Attribute Name | Values | Notes |
---|---|---|
volume | 0.0–1.0 | Specifies the initial volume setting of the audio element, in a range from 0.0 to 1.0. |
preload | none metadata auto | Requests a particular preload behavior to the browser, which the browser may or may not follow. |
muted | Specifies that the volume on the audio player should initially be muted. | |
loop | Specifies that the audio content should loop indefinitely once playback has begun. | |
controls | Toggles the display of audio playback controls. | |
autoplay | Specifies that the audio playback should begin immediately on page load. | |
src | url | Specifies the source file for an audio element. |