HTML | DOM IFrame width Property
The HTML DOM IFrame width Property is used to sets or returns the value of the width attribute of a Iframe Element. The width Attribute is used to specify the width of a Iframe Element.
Syntax:
- It return the width Property.
iframeObject.width
- It is used to set the width property.
iframeObject.width = pixels
Property Values:
- pixels: It specify the width of the Iframe Element in terms of pixels.
Return Value It returns a string value which represents the width of the Iframe in terms of pixels.
Example 1: This Example illustrates how to return the Iframe width Property.
<!DOCTYPE html> <html> <head> <title> HTML DOM iframe width Property </title> </head> <body style="text-align:center;"> <h1>GeeksforGeeks</h1> <h2>HTML DOM iframe width Property</h2> <iframe src= id="GFG" height="200" width="400"> </iframe> <br> <br> <button onclick="Geeks()">Submit</button> <p id="sudo" style="font-size:20px"></p> <script> function Geeks() { var x = document.getElementById("GFG").width; document.getElementById("sudo").innerHTML = x; } </script> </body> </html> |
Output:
Before Clicking On Button:

After Clicking On Button :

Example-2 : This Example illustrates how to set the Iframe width Property.
<!DOCTYPE html> <html> <head> <title> HTML DOM iframe width Property </title> </head> <body style="text-align:center;"> <h1>GeeksforGeeks</h1> <h2>HTML DOM iframe width Property</h2> <iframe src= id="GFG" height="200" width="400"> </iframe> <br> <br> <button onclick="Geeks()">Submit</button> <p id="sudo" style="font-size:20px"></p> <script> function Geeks() { var x = document.getElementById("GFG").width = "100%"; document.getElementById("sudo").innerHTML = x; } </script> </body> </html> |
Output :
Before Clicking On Button:

After Clicking On Button:

Supported Browsers: The browsers supported by HTML DOM IFrame width Property are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Apple Safari
- Opera
Recommended Posts:
- HTML | <iframe> width Attribute
- HTML | DOM IFrame src Property
- HTML | DOM IFrame name Property
- HTML | DOM IFrame srcdoc Property
- HTML | DOM IFrame sandbox Property
- HTML | DOM IFrame contentDocument Property
- HTML | DOM IFrame contentWindow Property
- HTML | DOM IFrame height Property
- HTML | DOM HR width Property
- HTML | DOM Style width Property
- HTML | Screen width Property
- HTML | DOM Video width Property
- HTML | DOM Object width Property
- HTML | DOM embed width property
- HTML | DOM Table width Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



