🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Expert Masterclasses.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
REFERENCEhtml

html Documentation

LOADING ENGINE...

HTML Audio Tag

Embed audio content in your web pages. Learn to use the <audio> tag with controls, multiple formats, and best practices.

audio.html
<!-- Audio Player -->
<audio controls>
<source
src="audio.mp3"
type="audio/mpeg" />
Your browser does not support audio.
</audio>
🎵
audio-player.html
1 / 8
🎵

Tutor:Audio content needs a standard way to be embedded in web pages. We use the <audio> tag, which is an HTML5 element that provides native audio playback without plugins.


Skill Matrix

UNLOCK NODES BY LEARNING AUDIO EMBEDDING.

Concept 1: The Audio Element

The <audio> tag is an HTML5 element that embeds audio content directly into web pages. It provides native audio playback without requiring external plugins, making it the standard way to add sound to modern websites.

System Check

What is the primary purpose of the <audio> tag?


Community Holo-Net

Share Audio Players

Created a custom audio player or playlist? Share your code and techniques.

Enjoying this guide?

Codesyllabus is 100% free and open-source. Support our mission, pay for server infrastructure, and fuel new tutorials by buying us a coffee!

HTML Audio Tag and Multimedia Embedding

Author

Pascual Vila

Frontend Instructor.

The <audio> tag is an HTML5 element used to embed audio content directly into web pages. It provides native audio playback without requiring external plugins like Flash, making it the standard way to add sound to modern websites.

Basic Usage

The simplest audio element uses the src attribute directly on the <audio> tag. However, for better browser compatibility, it's recommended to use <source> tags inside the audio element, allowing you to provide multiple formats.

Controls Attribute

By default, the audio element is invisible. Adding the controls attribute displays the browser's native playback controls, including play/pause, volume, and progress bar. This is essential for user interaction.

Multiple Formats

Different browsers support different audio formats. MP3 is widely supported, but providing OGG and WAV as alternatives ensures compatibility. The browser will try each <source> tag until it finds a format it supports.

Accessibility

Always include fallback content between the <audio> tags for browsers that don't support the element. This can include a download link or alternative content. Also, avoid autoplay without user interaction, as it can be disruptive and is often blocked by browsers.

Audio Tag Glossary

<audio>
HTML5 element used to embed audio content in web pages. Provides native audio playback without plugins.
<source>
Child element of <audio> that specifies audio sources. Allows multiple formats for browser compatibility.
controls attribute
Boolean attribute that displays the browser's native audio playback controls (play, pause, volume, progress).
autoplay attribute
Boolean attribute that starts audio playback automatically. Often blocked by browsers unless audio is muted.
preload attribute
Hints to the browser how to load the audio: none (don't preload), metadata (load metadata only), or auto (load entire file).
loop attribute
Boolean attribute that causes the audio to play continuously in a loop.
muted attribute
Boolean attribute that mutes the audio by default. Often used with autoplay to bypass browser restrictions.