Wednesday, June 04, 2008

CSS Hacks: DIV Height Problem and Solution

If you set height in css for a div and check it in IE and Firefox you will get two different heights.

Empty divs in IE have a minimum height, more or less equal to the current line-height.

The way to solve this is:

1) Put a comment inside the div: <div style="height: 10px;"><!-- --></div>
2) Put a inside the div and add this to its style: font-size:1px; line-height:0.