Open In App

How to set fullscreen iframe?

Last Updated : 12 Jul, 2025
Summarize
Comments
Improve
Suggest changes
Share
Like Article
Like
Report

To create a fullscreen <iframe> in HTML that covers the entire viewport, you can follow a few key steps involving HTML and CSS adjustments. The iframe element is commonly used to embed other web pages or documents within a webpage. Below is a detailed guide with examples of how to achieve this.

Steps to Make a Fullscreen <iframe>:

Reset margins and padding: Ensure that the page’s default margins and paddings are removed for the <html>, <body>, <div>, and <iframe> elements, to ensure the iframe takes up the full viewport.

html 
{
 overflow: auto;
}
 
html, body, div, iframe 
{
 margin: 0px; 
 padding: 0px; 
 height: 100%; 
 border: none;
}

Modify iframe behavior in CSS: Use CSS to transform the behavior of the iframe so that it stretches to cover the entire width and height of the screen.

iframe 
{
 display: block; 
 width: 100%; 
 border: none; 
 overflow-y: auto; 
 overflow-x: hidden;
}

Iframe properties for cross-browser compatibility: Add properties to the iframe tag to eliminate unwanted borders and ensure proper scrolling and sizing across different browsers.

<iframe src="myurl.in"
    frameborder="0" 
    marginheight="0" 
    marginwidth="0" 
    width="100%" 
    height="100%" 
    scrolling="auto"></iframe >

Example:

html
<!DOCTYPE html>
<html>

<head>
    <title>full screen iframe</title>
    <style type="text/css">
        html {
            overflow: auto;
        }
        
        html,
        body,
        div,
        iframe {
            margin: 0px;
            padding: 0px;
            height: 100%;
            border: none;
        }
        
        iframe {
            display: block;
            width: 100%;
            border: none;
            overflow-y: auto;
            overflow-x: hidden;
        }
    </style>
</head>

<body>
    <iframe src="https://en.wikipedia.org/wiki/HTML_element#Frames"
            frameborder="0" 
            marginheight="0" 
            marginwidth="0" 
            width="100%" 
            height="100%" 
            scrolling="auto">
  </iframe>

</body>

</html>

Output:

Example 2: Using <frameset> (Deprecated Approach)

Using a <frameset> is another way to achieve fullscreen behavior, but it’s important to note that the <frameset> element is now deprecated in HTML5, so it's recommended to use the modern <iframe> approach instead. However, for reference, here’s how it works:

html
<!DOCTYPE html>
<html>

<head>
    <title>full screen iframe</title>
</head>
<frameset rows="100%,*">
    <frame src=
"https://en.wikipedia.org/wiki/HTML_element#Frames">
        <noframes>

            <body>

            </body>
        </noframes>
</frameset>

</html>

Output:

Using an <iframe> with CSS is the best approach to embed another document or webpage in fullscreen. This can enhance the user experience by displaying embedded content seamlessly, and it allows for full control over the styling and behavior of the iframe on your webpage.

HTML is the foundation of webpages, is used for webpage development by structuring websites and web apps.You can learn HTML from the ground up by following this HTML Tutorial and HTML Examples.


Similar Reads