CSS Property - Height

Value: <length> | auto
Initial: auto
Applies to: block-level and replaced elements
Inherited: no
Percentage values: N/A

This CSS property can be applied to text, but it is most useful with replaced elements such as images. The height is to be enforced by scaling the image if necessary. When scaling, the aspect ratio of the image is preserved if the "width" property is "auto".


img.height {
height: 100px;

If the "width" and "height" of a replaced element are both "auto", these properties will be set to the intrinsic dimensions of the element.

If applied to a textual element, the height can be enforced with e.g. a scrollbar.


p.block {
height: 250px;
overflow: auto;

Negative values are not allowed.

CSS1 core: UAs may ignore the "height" property (i.e., treat it as "auto") if the element is not a replaced element.