allowfullscreen
an HTML attribute for the iframe tag

What's the syntax for allowfullscreen in HTML5?

Answers:

  • In HTML5, the allowfullscreen attribute is used as a Boolean attribute for the <iframe> element. When this attribute is present, it indicates that the iframe can be displayed in full-screen mode. The syntax for using allowfullscreen is as follows:

    <iframe src="your-video-url" allowfullscreen></iframe>
    

    You can also use the allow attribute to specify more granular permissions, including full-screen capabilities. Here’s how you can use the allow attribute together with allowfullscreen:

    <iframe src="your-video-url" allow="fullscreen" allowfullscreen></iframe>
    

    In this case, using allow="fullscreen" more explicitly communicates that full-screen is permitted.

    Example of Basic Usage

    Here’s a complete example of an iframe that might embed a video from a source that supports full-screen:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Fullscreen Example</title>
    </head>
    <body>
        <iframe src="https://www.example.com/video" width="640" height="360" allow="fullscreen" allowfullscreen></iframe>
    </body>
    </html>
    

    In this example, the embedded content from "example.com/video" can be viewed in full-screen mode.

Related Questions: