Here's a technique derived from an article on min-height and max-height in IE:
* html div#division {
height: expression(this.scrollHeight >= 200 ? "200px" : this.scrollHeight <= 40 ? "40px" : "auto");
}
div#division {
min-height: 40px;
max-height: 200px;
overflow: hidden;
}
The expression
value works only in IE, but works back as far as IE 5. Here, it keeps the height
property within the desired range. Standards-compliant browsers will ignore this declaration, and instead use the min-height
and max-height
rules.
Caveat: JavaScript must be enabled in IE for expression
to work.
The technique you are currently using might be preferred by the "use only pure CSS" crowd, but IMHO it is obscure and brittle. Using a non-standard, IE-specific value makes it clear that the code is written specifically to support IE. Not only is this self-documenting, it also makes it easier to migrate the IE-specific code into separate CSS files.