To automatically start playing an audio file, use the autoplay attribute:
<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 that in Chromium browsers, autoplay is generally restricted, but muted autoplay is consistently permitted. |
Include the muted attribute after autoplay to enable your audio file to start playing automatically (but muted):
<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> |
The numbers in the table indicate the earliest browser version that fully supports the <audio> element.