CSS Code For min-height in IE6 (and all other browsers)

CSS-Code-For-min-height

You probably already know that the min-height property works differently in IE6. There are two issues. First, if you specify height of a div, IE6 will take it as minimum height, where as other browsers, firefox, IE7 etc. will take it as normal height. And second, IE6 doesn’t understand min-height property.

Here’s one way to specify min-height to IE6 (and all the other browsers),

#myDiv
{
min-height:50px;
height:auto!important;
height:50px;
}

If you use this code, the minimum height of #myDiv will be 50px, and it will expand as required. It works for all browsers including IE6.

Another way to do the same thing is to use the underscore hack. Use this code,

#myDiv
{
min-height: 50px;
_height: 50px;
}

Although I recommend using the first way as the underscore hack is outdated and should not be used.

Leave a Comment