HTML Audio
The HTML <audio>
element is used to play an audio file on a web page.
The HTML <audio> Element
To play an audio file in HTML, use the <audio>
element:
Example
<audio controls> <source src="horse.ogg" type="audio/ogg"> <source src="horse.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio>
HTML Audio – How It Works
The controls
attribute adds audio controls, like play, pause, and volume.
The <source>
element allows you to specify alternative audio files which the browser may choose from. The browser will use the first recognized format.
The text between the <audio>
and </audio>
tags will only be displayed in browsers that do not support the <audio>
element.
HTML <audio> Autoplay
To start an audio file automatically, use the autoplay
attribute:
Example
<audio controls autoplay> <source src="horse.ogg" type="audio/ogg"> <source src="horse.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio>
Note: Chromium browsers do not allow autoplay in most cases. However, muted autoplay is always allowed.
Add muted
after autoplay
to let your audio file start playing automatically (but muted):
Example
<audio controls autoplay muted> <source src="horse.ogg" type="audio/ogg"> <source src="horse.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio>
HTML Audio Formats
There are three supported audio formats: MP3, WAV, and OGG. The browser support for the different formats is:
Browser | MP3 | WAV | OGG |
---|---|---|---|
Edge/IE | YES | YES* | YES* |
Chrome | YES | YES | YES |
Firefox | YES | YES | YES |
Safari | YES | YES | NO |
Opera | YES | YES | YES |
HTML Audio – Media Types
File Format | Media Type |
---|---|
MP3 | audio/mpeg |
OGG | audio/ogg |
WAV | audio/wav |
HTML Audio – Methods, Properties, and Events
The HTML DOM defines methods, properties, and events for the <audio>
element.
This allows you to load, play, and pause audios, as well as set duration and volume.
There are also DOM events that can notify you when an audio begins to play, is paused, etc.
42 Responses
order levaquin 250mg generic brand levofloxacin 250mg
avodart 0.5mg brand tamsulosin drug buy ondansetron 8mg online
buy generic aldactone 25mg buy valacyclovir 1000mg generic order fluconazole 100mg for sale
acillin cheap bactrim 960mg canada erythromycin price
fildena online order methocarbamol 500mg cheap robaxin price
order suhagra without prescription buy sildenafil 100mg for sale purchase estrace generic
lamotrigine 50mg cheap mebendazole 100mg over the counter order tretinoin cream generic
purchase tadalafil online cheap avana 100mg buy voltaren 50mg online cheap
isotretinoin 40mg drug buy amoxicillin 250mg pill zithromax 250mg tablet
indocin 75mg us terbinafine 250mg over the counter amoxicillin 500mg usa
tadalafil 40mg generic non prescription ed drugs buy sildenafil 50mg pill
order arimidex generic clarithromycin cheap purchase sildenafil generic
cialis 5mg generique pas cher sildenafil pour homme generique sildenafil 50mg
order prednisone for sale get cialis sildenafil 100mg canada
original cialis 10mg rezeptfrei sicher kaufen viagra für frauen sildenafil für männer
order isotretinoin 20mg pill order amoxicillin 250mg generic ivermectin 6mg tablet
modafinil 200mg for sale generic acetazolamide purchase acetazolamide pills
ramipril 5mg cost clobetasol drug azelastine 10 ml cheap
buy catapres sale order clonidine 0.1mg online cheap order spiriva 9mcg online
order buspirone 5mg sale order amiodarone 200mg generic oxybutynin uk
buy terazosin 5mg without prescription purchase sulfasalazine generic sulfasalazine 500mg generic
buy fosamax 70mg online cheap pepcid 40mg drug pepcid without prescription
benicar 10mg uk order acetazolamide 250mg online buy diamox 250 mg
prograf cheap urso 150mg generic ursodiol 150mg generic
order imdur 20mg pills purchase imuran generic micardis 80mg pills
bupropion 150 mg uk zyban 150 mg brand seroquel 100mg cheap
buy molnupiravir 200mg pills naprosyn 250mg brand lansoprazole pills
buy sertraline 50mg order sildenafil 100mg without prescription sildenafil 100mg price
buy imuran 100 mcg without prescription sildenafil us canadian viagra and healthcare
buy tadalafil 10mg generic buy viagra in new york viagra mail order usa
cialis 20mg ca oral cialis 5mg amantadine 100mg cheap
revia 50mg generic buy naltrexone pills abilify 30mg sale
order dapsone without prescription buy nifedipine generic aceon 8mg cost
medroxyprogesterone online buy brand praziquantel 600 mg buy periactin 4mg online cheap
purchase provigil sale canadian online pharmacy ivermectina 6 mg
buy fluvoxamine generic nizoral 200 mg usa glipizide generic
buy accutane 20mg sale order amoxicillin 1000mg for sale deltasone 40mg over the counter
purchase piracetam pills buy sildenafil for sale purchase viagra
order azithromycin 500mg sale prednisolone medication gabapentin 800mg generic
buy cialis 40mg generic buy cialis canada buy viagra tablets
lasix 100mg ca hydroxychloroquine buy online plaquenil 200mg pill
tadalafil 40mg for sale anafranil order online buy anafranil 25mg generic