How To Specify Minimum Height of a Div in CSS

CSS-Code-For-min-height

To specify minimum height of a div, you should use the min-height property of CSS. For instance, the code

#myDiv
{
min-height:30px;
}

will set the minimum height of #myDiv to be 30px.

You can specify the min-height as a fixed value (in px, em etc.) or as relative to the containing block (in %).

Except IE(6,7,8), you can also use the value inherit which signifies that the value of the min-height property should be inherited from its parent element, like this,

#myDiv
{
min-height:inherit;
}

Note that the min-height property does not include margin, padding or borders.

Also, the min-height property is supported in all major browsers, except the IE6. Although you can easily use this min-height for IE and all other browsers hack.

Leave a Comment