CSS height property
This CSS property sets the height of an element. It is used to set the height of content area of an element.
It does not include padding borders or margins, whereas it sets the height of the area inside the padding, border, and margin of the element. It can accept the length and percentage values. But it does not allow negative values.
If we set the height to a numeric value (like in px, %, etc.), the content can be overflow if it does not fit in the given height. We can manage the overflowing content by defining the overflow property.
If the height of the container is not explicitly defined, and the element is not absolutely positioned (i.e., position: absolute;), the value of height property is set to auto. The min-height and max-height properties can also be used to control the size.
The values of this property are tabulated as follows.
Now, we will see some of the examples to understand this property more clearly.
Here, we are using the keyword value auto and the length values of height property in px and em.Test it Now
Here, we are specifying the value of height property in percentage.Test it Now