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

Property
height Yes Yes Yes Yes Yes

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