allowfullscreen
an HTML attribute for the iframe tag

What is allowfullscreen in HTML?

Answers:

  • The allowfullscreen attribute in HTML is used in <iframe> elements to specify whether the iframe's content can be displayed in full-screen mode. When this attribute is present, it allows the user to enter full-screen mode for the content loaded in the iframe, typically triggered by a full-screen button in the iframe's user interface.

    Here’s how you can use it in an <iframe>:

    <iframe src="https://example.com" allowfullscreen></iframe>
    

    In this example, if the content at "https://example.com" supports full-screen mode, the user will be able to click a button to view that content in full-screen.

    The allowfullscreen attribute does not require a value; including it as a boolean attribute is sufficient to enable the feature. To enhance security and privacy, you might also see the allow attribute used in conjunction with allowfullscreen to specify the permissions granted to the iframe, like this:

    <iframe src="https://example.com" allow="fullscreen" allowfullscreen></iframe>
    

    In summary, allowfullscreen is an important attribute when dealing with iframes, especially when integrating content from other sources, such as videos or games, which you would like users to experience in a full-screen view.

Related Questions: