References

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

The HTML playsinline attribute

Attribute
In short

Adding playsinline to a <video> asks the browser to play it inside the page, not fullscreen. On iPhone, Safari needs it to autoplay a video inside the page, as in <video autoplay muted playsinline controls>. In browsers that play video inline anyway, it has no effect.

Overview

The HTML playsinline attribute is a boolean hint that a <video> should play within the page. Under the HTML standard, a browser may open a video in fullscreen or in a separate resizable window by default when playback starts, but should not do so when playsinline is present.

Leaving the attribute out doesn't force fullscreen. Most browsers already play every video inline, and in those browsers the attribute has no effect.

Safari supports playsinline from version 10 on macOS and iOS, Chrome from 75 on desktop and Android, and Edge from 79. Firefox doesn't support it on desktop or Android, and on Windows it plays video inside the page anyway.

Syntax

<video src="intro.mp4" autoplay muted loop playsinline controls></video>

Values

Value
Hints that the video should play inside the page, not fullscreen.

Example

Live example
<video id="clip" src="https://codeshack.io/web/example.mp4" width="192" height="108" controls muted></video>
<p>
  <button type="button" id="lower">clip.playsinline = true</button>
  <button type="button" id="upper">clip.playsInline = true</button>
</p>
<p id="msg" role="status">Press each button to see which one adds the attribute.</p>
<script>
const clip = document.getElementById('clip');
const msg = document.getElementById('msg');
document.getElementById('lower').addEventListener('click', function () {
  const before = clip.hasAttribute('playsinline');
  clip.playsinline = true;
  const changed = clip.hasAttribute('playsinline') !== before;
  msg.textContent = 'clip.playsinline = true ' + (changed ? 'changed the tag.' : 'left the tag as it was.');
});
document.getElementById('upper').addEventListener('click', function () {
  const before = clip.hasAttribute('playsinline');
  clip.playsInline = true;
  const after = clip.hasAttribute('playsinline');
  let result = 'did nothing, since this browser has no playsInline property.';
  if (after) result = before ? 'kept playsinline on the tag.' : 'added playsinline to the tag.';
  msg.textContent = 'clip.playsInline = true ' + result;
});
</script>

Best practices

  • Write playsinline as a bare attribute. Even playsinline="false" is invalid, and the browser still reads the attribute as present.
  • To open a video fullscreen, call requestFullscreen() from a click rather than leaving playsinline off. The call works on a playsinline video, though on iOS that API is available only on iPad.
  • Check inline playback on an iPhone, since a browser that plays video inline by default shows no sign of a missing playsinline.
  • Keep controls on a muted video that autoplays inline, so people can turn the sound on with the unmute button.

Frequently asked questions

What does playsinline do in a video tag?
The playsinline attribute asks the browser to play the video within the page rather than switching to fullscreen. It doesn't mute or start the video, which is why autoplay and muted appear beside it.
Do I still need webkit-playsinline, or is playsinline enough?
Plain playsinline is enough from Safari 10 on, the first version with the standard name. The prefixed form matters only for versions 8 and 9, and validator.nu reports it as an invalid attribute.
Does playsinline stop a video from going fullscreen?
No, playsinline only sets the starting view, and a browser may still offer fullscreen as a choice.
Why does setting video.playsinline in JavaScript leave the tag unchanged?
The property is playsInline in camel case, so assigning playsinline in lowercase only creates an ordinary property. Setting playsInline to true adds the attribute to the tag in browsers that support the property.
Do I need playsinline on a video that doesn't autoplay?
It can still matter, since the playsinline hint applies whenever a video plays, not only with autoplay. On iPhone, Safari switches any video without playsinline to fullscreen, even one started from the controls.