CSS height property

Description

CSS height property defines physical height of an element (box). The length units might be px, em, pt, in.

The min-height and max-height of child element is 150px and 200px respectively.

Syntax

height : auto | length | percentage | min-content | max-content

Property values

autoDefault

auto value means the height will be changed automatically according to the content.

height: auto;

length

The height of an element should be at least 300px.

height: 300px;

percentage

The height of an element should be 30% of the parent box.

height: 30%;

min-content

min-content value represents that the height of an element must be equal to or greater than the largest minimum height of some descendant item i.e. it depends upon the minimum height of child element.

In this case, the min-height of descendant element is 100px.

height: min-content;

max-content

max-content value means the height of an element must be equal to or less than the largest maximum height of some descendant item i.e. it depends upon the miximum height of child element.

In this case, the max-height of descendant element is 200px.

height: max-content;

Applicable to

It applies to all elements except non-replaced inline.

#CSS digger
Was this article helpful?

 
We are learning height property for different values such as min-height, max-height, and length.
×

Ctrl+D