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


Whereisstuff is simple learing platform for beginer to advance level to improve there skills in technologies.we will provide all material free of cost.you can write a code in runkit workspace and we provide some extrac features also, you agree to have read and accepted our terms of use, cookie and privacy policy.
© Copyright 2024 www.whereisstuff.com. All rights reserved. Developed by whereisstuff Tech.