min-height

Draft

Definition

The min-height CSS property is used to set the minimum height that an element can have. It ensures that the element’s height will not be smaller than the specified value.

The min-height property accepts various length units, such as pixels (px), percentages (%), viewport height (vh), or the auto keyword.

Here’s an example:

.container {
  min-height: 200px;
}

In this example, the .container class sets a minimum height of 200px for the element. If the content inside the element requires more space, the height of the element will expand accordingly.

You can also use other length units or percentage values to set a relative minimum height:

.container {
  min-height: 50%;
}

In this case, the .container class sets a minimum height of 50% of its containing element’s height. This allows the element to dynamically adjust its height based on the available space.

The min-height property is useful when you want to ensure that an element always has a minimum height, even when its content is sparse or absent. It helps maintain consistent proportions and prevents elements from becoming too small.