<audio>
Embeds an audio player.
Syntax
<audio src="file.mp3" controls></audio>Attributes
| Parameter | Type | Description |
|---|---|---|
| src | URL | The audio file address (or use `<source>`). |
| controls | — | Show the player. Without it the element is invisible. |
| loop | — | Optional. Play in a loop. |
| preload | none | metadata | auto | Optional. How much to load in advance. |
Examples
A player with the standard controls:
<p>Listen to a T-rex:</p>
<audio src="/media/t-rex-roar.mp3" controls></audio>A fallback for old browsers:
<audio controls preload="none">
<source src="/media/t-rex-roar.mp3" type="audio/mpeg">
<a href="/media/t-rex-roar.mp3">Download the sound</a>
</audio>Notes
Without controls the player is invisible and sound can only be started from JavaScript. The standard player looks different in each browser and can hardly be styled with CSS.
See also
Related recipes
In the tutorial
- Audio and video — The video and audio tags, the controls panel, autoplay, looping, several formats with source and subtitles.