IFrame width Attribute
Definition and usage
width
Attribute set or return the iframe element width attribute value.
The width attribute specifies the width of the iframe.
Hint:Tip: height attribute Set or return the height in the iframe: height attribute value.
Example
Example 1
Change the width of the iframe:
document.getElementById("myFrame").width = "400";
Example 2
Return the width of the iframe:
var x = document.getElementById("myFrame").width;
Example 3
Change the height and width of the iframe:
document.getElementById("myFrame").height = "400"; document.getElementById("myFrame").width = "400";
Syntax
Return the width attribute:
iframeObject.width
Set the width attribute:
iframeObject.width = pixels
Attribute value
Value | Description |
---|---|
pixels | Width in pixels (such as "100px" or just "100"). |
Technical Details
Return Value: | A string value representing the width of the iframe in pixels. |
---|
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
Related Pages
HTML Reference Manual:HTML <iframe> width Attribute