HTML autoplay Attribute

The autoplay attribute on a media player specifies that the element immediately starts playing the media file once the page is loaded.

Elements that accept this attribute are <audio>, and <video>.



An autoplay attribute on an <audio> element. To avoid surprises, we disabled autoplay 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">

For additional details see our HTML audio autoplay Reference.

Using autoplay

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

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

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


<tagname autoplay>

Elements accepting autoplay

These elements accept the autoplay attribute:

Elements Description
<audio> Creates an audio player -- see example above
<video> Creates a video player

<video> with autoplay

An autoplay attribute on a <video> tag.
Note: we disabled autoplay on this page. Click 'Try It live' to see it enabled.

<video width="320" autoplay>
  <source src="/media/movie.mp4" type="video/mp4">
  <source src="/media/movie.ogg" type="video/ogg">

For additional details see our HTML video autoplay Reference.

Browser support

Here is when autoplay support started for each browser:

1.0 Sep 2008
1.0 Sep 2002
1.0 Aug 1995
1.0 Jan 2006
1.0 Jan 2003

You may also like

Last updated on Sep 30, 2023