IFrame height attribute

Definition and usage

height The attribute sets or returns the height of the iframe element height attribute value.

height The attribute specifies the height of the iframe.

Tip:Use width attribute Set or return the height of the iframe width attribute value.

Example

Example 1

Change the height of the iframe:

document.getElementById("myFrame").height = "400";

Try it yourself

Example 2

Return the height of the iframe:

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

Try it yourself

Example 3

Change the height and width of the iframe:

document.getElementById("myFrame").height = "400";
document.getElementById("myFrame").width = "400";

Try it yourself

Syntax

Return the height attribute:

iframeObject.height

Set the height attribute:

iframeObject.height = pixels

Attribute value

Value Description
pixels Height in pixels (such as "100px" or just "100").

Technical Details

Return Value: A string value representing the height 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> height Attribute