The Wayback Machine - https://web.archive.org/web/20241122164108/https://www.geeksforgeeks.org/how-to-set-fullscreen-iframe/
Open In App

How to set fullscreen iframe?

Last Updated : 19 Sep, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

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.



Previous Article
Next Article

Similar Reads

How to check if an iframe is present in another iframe in JavaScript ?
In this article, we will see how to check if an iframe is present in another iframe, along with understanding its basic implementation with the help of a simple example. An iFrame is an HTML element that allows users to embed a webpage within another webpage. It's frequently used for displaying content from another website, such as a video or a soc
4 min read
How to load a hyperlink from one iframe to another iframe ?
HTML Iframe or inline frame allows embedment of multiple HTML pages in an HTML page. In this article, we will see how to change the content of one iframe using hyperlinks in another iframe. This can be achieved by the proper usage of the name attribute in the iframe tag and the target attribute in the anchor tag. The name attribute allows each inli
2 min read
How to create fullscreen search bar using HTML , CSS and JavaScript ?
In this article, you will learn how to create a full-screen search Bar. Here You will be required to create two divs. One for the overlay container and the other for the overlay content container. HTML Code: The first step is to create an HTML file. Here we will create the basic structure for the search bar. Here we will also use an icon for the se
2 min read
p5.js fullscreen() function
The fullscreen() function in p5.js is used to get the current fullscreen state of the user's browser window. If an argument is given, sets the sketch to fullscreen or not based on the value of the argument. If no argument is given, returns the current fullscreen state. Note that due to browser restrictions this can only be called on user input. Syn
1 min read
Web Window API | DOM Window fullscreen property
The Window interface has a fullscreen property which tells whether the window is displayed in fullscreen mode or not. Syntax: BoolVal = windowReference.fullScreen; Return value: Boolean True: If windows is in fullscreen mode. False: If windows are not in fullscreen mode. Example : <!DOCTYPE html> <html> <head> <title> Window
1 min read
How to make fullscreen toolbars using jQuery Mobile ?
jQuery Mobile is a web based technology used to make responsive content that can be accessed on all smartphones, tablets and desktops. In this article, we will be making fullscreen toolbars using jQuery Mobile. Approach: First, add jQuery Mobile scripts needed for your project. <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jqu
1 min read
jQuery Mobile Toolbar fullscreen Option
jQuery Mobile is a set of HTML5 based user system interaction widget toolbox used for various purposes build on top of jQuery. It is designed to build fast and responsive sites accessible to mobile, tabs, and desktops. In this article, we will use the jQuery Mobile Toolbar fullscreen option. When the fullscreen option is set to true, the toolbar wi
2 min read
Primer CSS Details Darkened Fullscreen Click Area
Primer CSS is an open-source component-rich CSS library that helps developers to develop beautiful and responsive websites which work on devices of any screen size. It has a wide range of components that fulfills the need of any website. In this article, we will be seeing Primer CSS Details Darkened Fullscreen Click Area. The details-overlay-dark c
2 min read
Primer CSS Details Fullscreen Click Area
Primer CSS is a free open-source CSS framework that is built upon systems that create the foundation of the basic style elements such as spacing, typography, and color. This systematic method makes sure our patterns are steady and interoperable with every other. Its approach to CSS is influenced by object-oriented CSS principles, functional CSS, an
2 min read
Angular PrimeNG Galleria FullScreen
Angular PrimeNG is an open-source UI component library for Angular Applications. Using the components provided by Angular PrimeNG, one can create stunning and responsive angular applications. In this post, we will see Angular PrimeNG Galleria FullScreen. Galleria is an advanced component to display images in an attractive manner. When the galleria
4 min read
Web API Fullscreen
Web API Fullscreen is a functionality found in web browsers that empowers web applications to make use of the entire screen space effectively converting the browser into a Fullscreen mode. This API enables you to utilize the screen to users ensuring that your content takes center stage and minimizing any potential distractions. In this article, we
5 min read
How To Change The Browser To Fullscreen with JavaScript?
In web development, there may be scenarios where you want to display your web application or a specific element in full-screen mode, covering the entire browser window. This can be useful for creating immersive experiences, such as games, presentations, or video players. JavaScript provides a built-in Fullscreen API that allows you to toggle the fu
2 min read
How to design Bootstrap Fullscreen Select feature for Mobiles ?
In this article, we will learn how to design Bootstrap fullscreen select feature for mobile devices. It provides advanced HTML full screen select functionality.It provides in and out animations.It provides open and close events function callbacks.It provides CSS3 animated buttons, dropdowns and texts.Please download the required pre-compiled librar
3 min read
Create Fullscreen Video Background with HTML and CSS
This article will show you how to add Full-screen background video with the help of HTML and CSS. Creating a fullscreen video background with HTML and CSS can add a dynamic and engaging element to your web page. To add the background video, we use HTML video tag. HTML video tag is used to add video, and CSS styles add its position and other styling
2 min read
Bootstrap 5 Fullscreen Modal
Bootstrap 5 Fullscreen Modal is used to create a modal that completely covers the entire screen of the user. Bootstrap 5 Fullscreen Modal Used CLasses: modal-fullscreen: This class is used to create Full Screen Modalmodal-fullscreen-*-down: This class is used to create a full-screen modal based upon breakpoints like sm, md, lg, xl,xxlSyntax: <di
2 min read
How to set height of an iframe element using HTML ?
The iframe in HTML stands for Inline Frame. The "iframe" tag defines a rectangular region within the document in which the browser can display a separate document, including scrollbars and borders. An inline frame is used to embed another document within the current HTML document. The HTML <iframe> height attribute is used to specify the heig
1 min read
How to enable extra set of restrictions for content in an iframe element in HTML5 ?
In this article, we will learn how to enable an extra set of restrictions for content in an iframe element in HTML5. Below are the approaches for enabling the set of instructions. Approach: The approach of this article is to learn how to enable an extra set of restrictions for the content in an iframe element in HTML5. The task can be done by using
2 min read
How to set full-screen iframe with height 100% in JavaScript?
To set a full-screen iframe with a height of 100% in JavaScript, it’s essential to manipulate the iframe's properties and styles dynamically. This process involves adjusting the iframe's dimensions to cover the entire viewport. Below are the approaches to set full-screen iframe: Table of Content Using height propertyUsing window.innerHeight propert
2 min read
HTML | <iframe> width Attribute
The HTML <iframe> width attribute is used to specify the width of the <iframe> in terms of pixels. Syntax: <iframe width="pixels"> Attribute Values: It contains single value pixel which specifies the width of the iframes in terms of pixels. Below example illustrates the use of <iframe> width attribute in HTML: Example: C/C++
1 min read
HTML | DOM IFrame Object
The IFrame Object property in HTML DOM is used to create and access the <iframe> element within the object. An inline frame is used for embedding another document within the current HTML document. Syntax: It is used to access a <iframe> element.var x = document.getElementById("myframe");It is used to create a <iframe> element.var
3 min read
HTML | <iframe> height Attribute
The HTML <iframe> height attribute is used to specify the height of the <iframe> in terms of pixels. Syntax: <iframe height="pixels"> Attribute Values: It contains single value pixel which specifies the height of the iframes in terms of pixels. Below example illustrates the use of <iframe> height attribute in HTML: Example:
1 min read
HTML | <iframe> src Attribute
The HTML <iframe> src attribute is used to specify the URL of the document that are embedded to the <iframe> element. Syntax: <iframe src="URL"> Attribute Values: It contains single value URL which specifies the URL of the document that is embedded to the iframe. There are two types of URL link which are listed below: Absolute URL
1 min read
HTML | <iframe> name Attribute
The HTML iframe name Attribute is used to specify a reference for an <Iframe> Element. The name attribute is also used as a reference to the elements in a Javascript. Syntax: <iframe name="name"> Attribute Values: name: It specify the name for the Iframe element. Example: C/C++ Code &lt;!DOCTYPE html&gt; &lt;html&gt;
1 min read
HTML DOM IFrame src Property
The HTML DOM IFrame src Property is used to set or return the value of the src attribute of the <iframe> element. This attribute is used to specify the URL of the document that is embedded in the iframe element. Syntax: It returns the src Property. iframeObject.srcIt is used to set the src Property. iframeObject.src = URL Property Values: It
2 min read
HTML DOM IFrame width Property
The HTML DOM IFrame width Property is used to sets or return the value of the width attribute of a Iframe Element. The width Attribute is used to specify the width of an Iframe Element. Syntax: It returns the width Property.iframeObject.widthIt is used to set the width property.iframeObject.width = pixels Property Values: pixels: It specifies the w
2 min read
HTML DOM IFrame height Property
The HTML DOM IFrame height Property is used to sets or return the value of the height attribute of an Iframe Element. The height attribute is used to specify the height of an Iframe Element. Syntax: It returns the height Property. iframeObject.heightIt is used to set the height property. iframeObject.height = pixels Property Values: pixels: It spec
2 min read
HTML DOM IFrame name Property
The HTML DOM IFrame name property is used to set or return a value of the name attribute of the Iframe element. The name attribute is used as a reference for the element in JavaScript. Syntax: It returns the name property.iframeObject.nameIt is used to set the name property.iframeObject.name = nameProperty Values: name: It is used to specify the na
2 min read
HTML DOM IFrame srcdoc Property
The HTML DOM IFrame srcdoc property is used to set or return the value of a srcdoc attribute of an <Iframe> element. The srcdoc attribute is used to specify the HTML content of the document in the <Iframe> element. It can be used together with the sandbox and seamless attributes. Syntax: It returns the srcdoc property.iframeObject.srcdo
2 min read
How to insert HTML content into an iFrame using jQuery?
Here is the task to insert HTML content into an iFrame using jQuery. To do so, we can use the jQuery contents() method. The .contents() method: It returns all the direct children, including text and comment nodes for the selected element. Syntax: $(selector).contents()Find the iframe in the body section.Get the value to be inserted in the iframe in
2 min read
HTML | <Iframe> frameborder Attribute
The HTML Iframe frameborder Attribute is used to specify whether or not to display the border around the content of an <Iframe> Element. Syntax: <iframe frameborder="1 | 0"> Attribute Values: 0: It has a Default value. It sets the border on one state. 1: It sets the border on-off state. Note: This attribute does not support in HTML5 as
1 min read
three90RightbarBannerImg