Skip to main content
height property

Sets or retrieves the height of the object.


height: height | percentage | auto

Property values




Floating-point number followed by an absolute units designator (cm, mm, in, pt, or pc) or a relative units designator (em, ex, or px). For more information about the supported length units, see CSS Values and Units Reference.


Integer followed by a percent sign (%). The value is a percentage of the height of the parent object, which must be specified explicitly. Negative values are not allowed.

CSS information

Applies ToAll elements
Initial Value


If you specify the height property of an img object but not the width property, the width is proportional to the height according to the dimensions of the image source file.

To perform operations on the numeric value of this property, use pixelHeight or posHeight.

As of Microsoft Internet Explorer 6, when you use the !DOCTYPE declaration to specify standards-compliant mode, this property specifies the distance between the top and bottom edges of the content box—that is, within the padding.

When the !DOCTYPE declaration does not specify standards-compliant mode, and with earlier versions of Windows Internet Explorer, this property includes the object's content box, plus the values of the following properties: border-top, border-bottom, padding-top, and padding-bottom. Subtracting the sum of the values of these properties from the value of the height property equals the height of the parent object's content box.


This example uses an inline style sheet to set the height of an image to 4 centimeters.

Code example:

<img src="sphere.jpg" style="height: 4cm">

This example uses inline scripting to change the height of an image when an onclick event occurs.

Code example:

<button onclick="'1cm'">Shrink sphere</button>

See also

Measuring Element Dimension and Location with CSSOM in Internet Explorer 9
Other Resources
CSS Enhancements in Internet Explorer 6