The HTML playsinline attribute
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
<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
playsinlineas a bare attribute. Evenplaysinline="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?
Do I still need webkit-playsinline, or is playsinline enough?
Does playsinline stop a video from going fullscreen?
Why does setting video.playsinline in JavaScript leave the tag unchanged?
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.






















