Skip to main content
height attribute | height property

Sets or retrieves the height of the object.


HTML<element height="p" ... >

p = object.height


Property values

Type: Variant


Integer that specifies the height of the object, in pixels.


Integer, followed by a percent sign (%). The value is a percentage of the height of the parent object.


If the height property of an img is specified, but the width property is not specified, the resulting width of the img is sized proportionally according to the specified height property and the actual width (in pixels) of the image in the source file.

Consider the following:

Dimensions of image in source file (pixels):100 X 50 (W X H)
Specified image height:2in
Specified image width:not specified
Resulting image height:2in
Resulting image width:4in ((100 / 50) * 2 inches)


If you specify the height property of an img, and the height and width of the image in the source file are identical, the width of the image matches the height.

If you specify the height property and the width property of an img, the resulting image dimensions matches those specified.

Percentage values are based on the height of the parent object.

When scripting the height property, use either the pixelHeight or posHeight property to numerically manipulate the height value.

If dynamic changes are intended for the height and width, the original values should be set through style (for example, "style=''height:200px; width:200px'') rather than through the height and width attributes.

This property specifies the calculated height of the object, in pixels. For table rows and table cells, this property has a range of 0 to 32750 pixels.

If you set the value of the corresponding HTML attribute using a percentage, this property specifies the height, in pixels, represented by that percentage.

The scripting property is read/write for the img object, but read-only for other objects.

For more information about how to access the dimension and location of objects on the page through the Dynamic HTML (DHTML) Document Object Model (DOM), see Measuring Element Dimension and Location with CSSOM in Internet Explorer 9.

In Microsoft Internet Explorer 5 it is possible to set the height property, but doing so has no effect on the rendering of the frame.

See also

input type=image