allowfullscreen
an HTML attribute for the iframe tag

Can the allowfullscreen attribute be used with other HTML tags?

Answers:

  • Yes, the allowfullscreen attribute is primarily associated with the <iframe> tag, where it indicates whether the iframe can be displayed in full-screen mode. However, it is not limited to just the <iframe> element in recent HTML standards.

    In addition to <iframe>, the allowfullscreen attribute can also be applied to the <video> and <audio> elements as part of the media elements that might want to go full screen. This allows users to watch videos or listen to audio in a more immersive experience.

    Here's an example usage with the <iframe>:

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

    And with a <video> element:

    <video controls allowfullscreen>
        <source src="movie.mp4" type="video/mp4">
        Your browser does not support the video tag.
    </video>
    

    It is important to note that while several elements can accept this attribute, support may vary across browsers and the actual ability to enter full-screen mode may depend on specific implementations or other attributes (like the use of webkit-playsinline for video on mobile devices). Always refer to the latest documentation for the most accurate information.

Related Questions: