CSS2 » Properties » height

Version: Level 1

Compability: IE4+  N6

height : length | percentage | auto
The auto value directs the browser to automatically calculate the height. If both the width and height are set to auto, the dimensions of the text or image element remains unchanged. By declaring auto, you can ensure that any previous declaration will not effect the height of the selected element.
The percentage value is based upon the total height being defined as 100%.
The length value can be in any of the following seven dimensions. Use the abbreviation.
Length Abbrev.
centimeters cm
ems em
inches in
millimeters mm
picas pc
pixels px
points pt

The height property allows you to set the height of an element of text or an image. This property is not inherited.

For example, you could embed an image into a specified position within a text using the float property. Then use the height and/or width properties to specify an exact size for the image. If you set the height of an element to a specified value and set the width property to auto, the element will be scaled proportionally (i.e., you maintain the aspect ratio).


img { height: 150mm; }
img { height: 2.85in; }
img { height: 45pc; }
img { height: 36pt; }
img { height: 50%; }
img { height: auto; }
img {
height:  3.0in
width: auto
Language(s): CSS2
<img src="/images/guru.gif">
<img src="/images/guru.gif" style="height: 55px; width: auto;">
Devguru logo
Devguru logo
Language(s): CSS2

See Also: