HTML: audio
The <audio> element embeds sound and can provide native playback controls.
What you will learn
- How to embed audio with controls
- How to provide a source and fallback message
- Why transcripts and user controls matter
Minimal example
<audio controls>
<source src="podcast.mp3" type="audio/mpeg">
Your browser does not support audio playback.
</audio>The controls attribute lets users play, pause, seek, and change the volume. The text inside the element is a fallback for unsupported browsers.
Provide a transcript
For spoken content, provide a text transcript near the player. A transcript helps people who cannot hear the audio and users who need to search or read quietly.
Autoplay and accessibility
Do not start sound unexpectedly. Autoplay can be disruptive and browsers may block it. Let users choose when playback begins and provide a clear pause control.
Common mistakes
- Do not remove native controls unless the custom player is fully accessible.
- Provide a fallback format or message when practical.
- Do not rely on audio alone to communicate important information.