THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Image height Property

Image Object Reference Image Object

Example

Change the height of an image to 300px:

document.getElementById("myImg").height = "300";
Try it yourself »

Definition and Usage

The height property sets or returns the value of the height attribute of an image.

The height attribute specifies the height of an image.

This property can also return the height of an image that has been styled with CSS (See More Examples).

Tip: Use the width property to set or return the value of the width attribute of an image.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The height property is supported in all major browsers.


Syntax

Return the height property:

imageObject.height

Set the height property:

imageObject.height=pixels

Property Values

Value Description
pixels The height in pixels (e.g. height="100")

Technical Details

Return Value: A Number, representing the height of the image, in pixels

More Examples

Example

Return the height of an image:

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

The result of x will be:

98
Try it yourself »

Example

Change the height and width of an image to 300px:

document.getElementById("myImg").height = "300";
document.getElementById("myImg").width = "300";
Try it yourself »

Example

Return the height of an image that has been styled with CSS:

var x = document.getElementById("myImg").height;
Try it yourself »

Related Pages

HTML reference: HTML <img> height attribute


Image Object Reference Image Object