X

Headline

This is an important message requiring you to make a choice if you're based in the EU.

CSS min-height Property

The min-height property sets the minimum height of an element. This property prevents the height property's value from becoming smaller than the value specified for min-height.

The min-height property overrides height property and max-height property.

The property takes a CSS length (px, pt, em, etc.) or a percentage.

Negative values are not accepted.

Initial Value none
Applies to All elements, but non-replaced inline elements, table columns, and column groups.
Inherited No.
Animatable Yes. Height is animatable.
Version CSS2
DOM Syntax object.style.minHeight = "100px";

Syntax

min-height: length | initial | inherit;

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      div {
      min-height: 50px;
      background-color: #8ebf42;
      }
    </style>
  </head>
  <body>
    <h2>Min-height property example</h2>
    <div>The text area's minimum height is defined as 50px.</div>
  </body>
</html>

Here, the minimum height of the element is specified by "3cm":

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      p {
      background-color: #ccc;  
      }
      p.example {
      min-height: 3cm;
      }
    </style>
  </head>
  <body>
    <h2>Min-height property example</h2>
    <h3>Min-height: none.</h3>
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
    <h3>Min-height: 3cm.</h3>
    <p class="example">Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
  </body>
</html>

Values

Value Description
auto Sets the minimum height. It is the default value of this property.
length Defines minimum height in px, pt, cm, etc. Default value is 0.
% Sets the minimum height in % of containing element.
initial Makes the property use its default value.
inherit Inherits the property from its parents element.



Do you find this helpful?

Related articles