HTML <audio> tag
- closing tag
- required
- void element
- no
- lives inside
- anywhere in <body>
- typically holds
- fallback text, or one or more <source> tags
Where it goes
Anywhere in <body>. Same src and controls pattern as <video>.
Example
<audio src="clip.mp3" controls></audio>Open this example in the editor →
Common mistakes
- Forgetting controls. Without it there is no way to play, pause or change the volume.
- Setting autoplay. Browsers block sound that starts on its own, and where it works it is an unwelcome surprise.
- Offering only one format. Not every browser plays every one. Nested <source> tags with an mp3 and an ogg cover nearly everyone.