This reference is built into PageRIJ — a live HTML, CSS & SVG authoring and learning environment.

HTML <audio> element

The <audio> element embeds sound into a web page. It can present music, speech, pronunciation examples, interviews, podcasts, or other audio content.

The simplest form uses src to point to one file. Alternatively, omit that attribute and place <source> elements inside the player to offer several formats. The browser considers those sources in order and selects one it can use.

The boolean controls attribute shows the browser's built-in playback controls. Their appearance and available options vary by browser and device. Without it, provide another usable interface for starting and stopping playback.

The preload attribute is a loading hint: none requests no advance loading, metadata requests information such as duration, and auto permits loading the whole resource. The browser may adjust loading to suit its policies and the user's connection.

The boolean autoplay attribute requests automatic playback, but browser policies may block it, especially when sound is audible. The loop attribute repeats playback, and muted sets the initial muted state. Boolean attributes are enabled by their presence: autoplay="false" still requests autoplay; omit the attribute to turn it off.

Content inside <audio> is fallback for browsers that do not support the element. It is not displayed as an error message when a supported player cannot load a file. Put a download link and, for speech or other meaningful audio, a transcript outside the player so they remain available.

The example plays a quiet, three-second tone when you press Play. Its text alternative describes the sound, and its download link uses the same file as the player.

Attributes: src, crossorigin, preload, autoplay, loop, muted, controls, GLOBALS.

Typical layout:
<audio controls preload="metadata"
  src="examples/steady-tone.wav">
  Your browser does not support the audio element.
</audio>
<p>Audio description: a steady tone plays for three seconds.</p>
<p><a href="examples/steady-tone.wav" download>Download the audio</a></p>
Visual representation:

Audio description: a steady tone plays for three seconds.

Download the audio