References

Beginner-friendly references for web development, with live, editable examples.

The HTML autoplay attribute

Attribute All modern browsers Updated
Quick answer

The HTML autoplay attribute starts playing the media as soon as it can, without waiting for the user. It is used on the <audio> and <video> elements.

Overview

The autoplay attribute starts playing the media as soon as it can, without waiting for the user. It applies to the <audio> and <video> elements.

Most browsers only allow autoplay when the video is also muted. Use autoplay sparingly — auto-playing audio is intrusive and an accessibility problem.

Syntax

<video src="clip.mp4" autoplay muted playsinline></video>

Values

Value
A boolean attribute — present or absent.

Best practices

  • Provide controls so users can play, pause and seek.
  • Browsers only allow autoplay when the media is also muted.
  • Always add captions with a <track> for accessibility.
  • Offer multiple formats with nested <source> elements for broad support.

Accessibility

Auto-playing media can be disorienting and may interfere with screen readers. Avoid auto-playing audio, keep videos muted, and always provide controls and a way to pause.

Frequently asked questions

What does the autoplay attribute do?
Starts media playback automatically.
Why won't my video autoplay?
Browsers block autoplay with sound. The media must be muted to autoplay.
How do I make media accessible?
Add captions via a <track>, and provide a transcript for audio-only content.
Which elements use the autoplay attribute?
It is an element-specific attribute, used on the <video>, <audio>, <source> and <track> elements.