HTML autoplay Attribute

Beginner
6 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The autoplay attribute is a boolean attribute on <video> and <audio>. When present, the browser should begin playback as soon as it has enough media data — without waiting for the user to press play.

Modern browsers block autoplay with sound. Silent media (no audio track) or media with muted usually can autoplay. Pair autoplay with controls so users can pause or unmute.

Baseline · Widely available.

Not deprecated and not experimental. The attribute is widely supported; whether playback actually starts still depends on each browser’s autoplay policy.

Unexpected sound hurts UX.

MDN advises careful use. Prefer muted video for decorative clips. Avoid surprising users with audible autoplay — it fails accessibility expectations and is often blocked anyway.

HTML Syntax

syntax.html
<video|audio autoplay>

Boolean attribute: write autoplay alone. autoplay="false" does not disable it — remove the attribute entirely.

Attribute Values

autoplay itself has no keyword list. Related attributes decide whether browsers allow it:

Value / pairingDescriptionTry it
autoplay (present)Request automatic start when enough data is bufferedTry it
OmittedNo automatic start from this attributeTry it
autoplay + mutedUsual pattern that passes most autoplay policiesTry it
+ playsinlineHelps iOS Safari play in place (not forced fullscreen)Try it
+ loop + controlsBackground/hero loops with user pause/unmute controlsTry it

Live Preview

Toggle muted, then press Restart. Unmuted autoplay is often blocked until you interact with the page.

Options

Sample clip from /video/count.mp4. Keep muted for reliable autoplay.

Video

autoplay + muted

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Muted Video Autoplay

MDN’s recommended pattern for clips that should start without a click.

HTML
<video width="400" height="225" controls autoplay muted playsinline>
  <source src="/video/count.mp4" type="video/mp4">
  Your browser does not support the video element.
</video>
Try It Yourself

How It Works

  1. autoplay requests playback as soon as enough data is ready.
  2. muted makes the clip inaudible so most browsers allow autoplay.
  3. playsinline keeps playback in-page on many mobile Safari builds.
  4. controls lets users pause or unmute when they want sound.

Example 2 — Audio with Autoplay

Audible audio autoplay is usually blocked until the user interacts with the site.

HTML
<audio controls autoplay>
  <source src="/audio/count.mp3" type="audio/mpeg">
  <source src="/audio/count.ogg" type="audio/ogg">
  Your browser does not support the audio element.
</audio>
Try It Yourself

How It Works

  1. autoplay on <audio> asks for automatic start with sound.
  2. Policy check. Browsers commonly require a prior click/tap/keypress, mute, or site allowlist.
  3. Always keep controls so playback remains user-operable when autoplay fails.
  4. Prefer user-started audio for music or narration — unexpected sound is jarring.

Example 3 — Looping Muted Hero Clip

Background-style video: silent, inline, looping, with controls for pause.

HTML
<video
  width="400"
  height="225"
  autoplay
  muted
  loop
  playsinline
  controls
  poster="/images/html-autoplay-attribute.webp">
  <source src="/video/count.mp4" type="video/mp4">
  Your browser does not support the video element.
</video>
Try It Yourself

How It Works

  1. muted + autoplay satisfy typical autoplay policies.
  2. loop restarts the clip for a continuous background feel.
  3. playsinline avoids fullscreen takeover on many phones.
  4. poster shows a still if playback is delayed or blocked.

Edge Cases & Pitfalls

Most “broken autoplay” reports are browser policy, not missing HTML.

policy

Sound is usually blocked

Autoplay of audible media needs mute, a user gesture, or allowlisting. Silent video or muted is the reliable path.

boolean

autoplay="false" still autoplays

Presence of the attribute means true. Delete the attribute to turn autoplay off (same rule for muted).

script

play() counts as autoplay

Calling media.play() outside a user-input handler follows the same blocking rules. Prefer the HTML attribute when you can; handle the rejected promise if you use play().

mobile

Add playsinline on iOS

Without it, Safari may force fullscreen and refuse the muted-autoplay pattern you expect on the page.

a11y

Always offer pause

Moving or flashing content needs a way to stop. Keep controls (or an equivalent pause control) on autoplaying media.

Browser Support

autoplay is an HTML attribute on media elements in the browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

autoplay

The attribute is widely supported on audio and video. Actual autoplay success depends on muted state, user gestures, and each browser’s policy — not only on the attribute existing.

97% Attribute support (approx.)
Google Chrome Supported · blocks audible
Full support
Mozilla Firefox Supported · blocks audible
Full support
Apple Safari Supported · needs playsinline
Full support
Microsoft Edge 79+
Full support
Opera Modern · Full
Full support
Samsung Internet Modern · Full
Full support
Internet Explorer 9+ (partial media)
Partial
autoplay Widely supported · policy varies

Bottom line: Write muted + controls + playsinline for decorative video. Treat unmuted autoplay as unreliable and often undesirable.

Key Takeaways

  • Role: boolean hint on audio/video to start playback without a Play click.
  • Mute to succeed: audible autoplay is usually blocked; use muted or no audio track.
  • Mobile: add playsinline; keep controls for pause/unmute.
  • Boolean trap: presence = on; autoplay="false" still means on.

One line: autoplay works best when media is silent (or muted) and users can still pause it.

Frequently Asked Questions

On audio or video, it asks the browser to start playback as soon as enough media data is available, without the user pressing play.
Most browsers block autoplay with sound. Mute the media (muted attribute or no audio track), wait for a user gesture, or rely on site allowlisting. Prefer muted autoplay for background clips.
No. autoplay is a boolean attribute. If the attribute is present at all, it is treated as true. Remove the attribute entirely to disable it.
The HTML audio and video elements. Scripted play() outside a user gesture is also treated as autoplay and follows the same browser policies.
On iOS Safari, playsinline helps video play in place instead of forcing fullscreen, which is often required for reliable muted autoplay.
Usually no. Unexpected sound harms accessibility and UX. Prefer user-started playback with visible controls.

Next: axis

Continue alphabetically through HTML attributes.

axis tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful