Dofactory.com
Dofactory.com

HTML <audio> autoplay Attribute

The autoplay attribute on an <audio> tag specifies that the audio starts playing once the page is loaded.

Without this attribute the user must start the audio.

Example

#

An autoplay attribute on an <audio> tag. To avoid surprises, autoplay is disabled on this page. Click 'Try It live' to see it enabled.

<audio autoplay controls>
  <source src="/media/epic.mp3" type="audio/mpeg">
  <source src="/media/epic.wav" type="audio/wav">
</audio>

Using autoplay

With this attribute, the audio file will start playing even before the entire file is loaded.

Suddenly playing an audio may startle users because they are not expecting it.

It is usually best to give users control over when to start.


Syntax

<audio autoplay>

Browser support

Here is when autoplay support started for each browser:

Chrome
4.0 Jan 2010
Firefox
3.5 Jun 2009
IE/Edge
9.0 Mar 2011
Opera
11.5 Aug 2011
Safari
4.0 Jun 2009

You may also like

 Back to <audio>

Last updated on Sep 30, 2023




Guides