The HTML autoplay attribute
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
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.