The HTML audio element is used to embed sound content on a webpage.
Audio is commonly used for podcasts, background music, voice tutorials, alerts, and learning platforms.
The audio Element
The audio element defines a container for playing sound files directly in the browser.
It supports multiple audio formats and works across modern browsers.
In this example:
- audio defines the audio player
- src specifies the audio file location
By default, no controls are shown to the user.
Adding Audio Controls
The controls attribute adds play, pause, and volume controls so users can interact with the audio.
Supported Audio Formats
Common audio formats supported by browsers include:
- MP3
- WAV
- OGG
MP3 is the most widely used format.
Using the source Element
The source element allows multiple audio formats to be provided for better browser compatibility.
The browser automatically selects the first supported audio format.
This ensures better compatibility across different browsers and devices.
Common Uses of HTML Audio
- Podcasts and interviews
- Voice instructions
- Learning tutorials
- Notification sounds
Why the Audio Element Matters for Jobs
Modern websites often include audio content.
Frontend developers are expected to know how to embed and manage audio professionally.
Practice Task
Embed an audio file with controls. Try adding multiple source formats for better compatibility.
What You Will Learn Next
In the next lesson, you will learn how to embed videos using the HTML video element.