Advertisement

Google Ad Slot: content-top

Audio Tag


What is HTML Audio?

The <audio> tag is used to embed sound content in a web page. It can play formats like MP3, WAV, and OGG.


Basic Example
<audio controls>
<source src="/assets/audios/sample.mp3" type="audio/mpeg">
</audio>
Try it yourself

Attributes

Attribute

Description

controls

Displays audio controls like play, pause, volume, etc.

autoplay

Starts playing the audio automatically (muted by default).

loop

Loops the audio when it ends.

muted

Mutes the audio by default.

preload

Specifies how the audio should be loaded (none, metadata, auto).


Supported File Formats

Format

MIME Type

MP3

audio/mpeg

OGG

audio/ogg

WAV

audio/wav


Example with Multiple Sources
<audio controls>
<source src="/assets/audios/sample.ogg" type="audio/ogg">
<source src="/assets/audios/sample.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
Try it yourself

Example: Looping & Autoplay
<audio controls autoplay loop muted>
<source src="/assets/audios/sample.mp3" type="audio/mpeg">
</audio>
Try it yourself