<audio>: The AUDIO Element
Last updated: 2026-10-13
<audio>The AUDIO Element
Embeds an audio player; often paired with source for multiple formats to ensure compatibility.
| Category | Links & Media |
|---|---|
| Content Model | Embedded content |
| Allowed Parents | Any element that accepts flow content |
| Content Tag | Yes — requires closing </audio> tag |
| Status | Standard |
📝 Syntax
<audio controls>audio content</audio>
⚙️ Attributes
This element supports the global attributes plus the following:
| Attribute | Value | Description |
|---|---|---|
src | Audio file URL (for a single source; use source for multiple). | |
controls | Shows play/pause, volume and other controls. | |
autoplay | Starts playing on load (usually needs muted). | |
loop | Replays from the start when finished. | |
muted | Starts muted by default. | |
preload | Preload hint: none/metadata/auto. |
▶ Example
Edit the code below and see the live result in the playground:
🌐 Browser Support
| Browser | |||||
|---|---|---|---|---|---|
| <audio> | ✓ v1 | ✓ v12 | ✓ v1 | ✓ v1 | ✓ v1 |
| Supported in all major browsers | |||||
Tip: Add controls to show playback UI; autoplay usually requires muted to work (browser policy).
❓ FAQ
QHow do I make audio compatible with multiple formats?
AProvide multiple
<source> elements; the browser picks the first one it can play: <source src='a.ogg'><source src='a.mp3'>. Recommended: at least mp3 (widest support) plus ogg/opus (open formats); show the fallback text inside the tag when nothing is supported.QWhy does audio autoplay often fail?
ABrowsers have autoplay policies: media with sound requires prior user interaction with the page, otherwise it is blocked. Working approaches: muted autoplay (
autoplay muted) is always allowed, or call audio.play() after listening for the first user interaction.QWhat content can go inside the audio tag?
Asource children plus fallback content:
<audio controls><source src='a.mp3'>Your browser does not support audio playback.</audio>. The fallback text shows in environments without audio support; modern browsers almost never render it, but keeping it is good practice.🏷️ Related Tags
💡 Related Cases
More case studies coming soon — check back later.