allowfullscreen
an HTML attribute for the iframe tag

Can I make an embedded video go fullscreen without allowfullscreen?

Answers:

  • To make an embedded video go fullscreen, you typically need to use the allowfullscreen attribute in the <iframe> tag for videos. This attribute is required by most modern browsers to allow the video to enter fullscreen mode for security and user experience reasons.

    Here's a basic example of an iframe with the allowfullscreen attribute:

    <iframe 
        width="560" 
        height="315" 
        src="https://www.youtube.com/embed/VIDEO_ID" 
        frameborder="0" 
        allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" 
        allowfullscreen>
    </iframe>
    

    If you attempt to trigger fullscreen mode programmatically (e.g., using JavaScript) on an iframe without allowfullscreen, the request will likely be blocked by the browser.

    While there are workarounds for triggering fullscreen mode without the allowfullscreen attribute (such as using a video player that doesn’t rely on iframes), these would generally require additional coding and possibly using custom video players like Video.js or similar libraries. However, for standard web videos embedded from platforms like YouTube or Vimeo, using the allowfullscreen attribute is the best and most standard approach.

Related Questions: