THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

IFrame width Property

Frame/IFrame Object Reference IFrame Object

Example

Change the width of an iframe:

document.getElementById("myFrame").width = "400";
Try it yourself »

Definition and Usage

The width property sets or returns the value of the width attribute in an iframe element.

The width attribute specifies the width of an iframe.

Tip: Use the height property to set or return the value of the height attribute in an iframe.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The width property is supported in all major browsers.


Syntax

Return the width property:

iframeObject.width

Set the width property:

iframeObject.width=pixels

Property Values

Value Description
pixels The width in pixels (like "100px" or just "100")

Technical Details

Return Value: A String, representing the width of the iframe, in pixels

More Examples

Example

Return the width of an iframe:

var x = document.getElementById("myFrame").width;

The result of x will be:

250
Try it yourself »

Example

Change the height and width of an iframe:

document.getElementById("myFrame").height = "400";
document.getElementById("myFrame").width = "400";
Try it yourself »

Related Pages

HTML reference: HTML <iframe> width attribute


Frame/IFrame Object Reference IFrame Object