(Just when I thought I've encountered all the strange IE CSS bugs, here comes another one. Is there a name for this double-vertical-padding bug?)
After creating a simple test case that worked perfectly in browsers like FF and Opera, I was surprised to find issues in IE 6 and IE 7. The page below illustrates the problem.
Edit: To view the issue, visit: http://jsbin.com/efele
Open it in both IE and FF to compare.
I'm curious, what is the official name for this bug? (Is it documented somewhere like on this page?) I have experience with other float-related bugs like the 3px jog bug and the double-margin bug, but encountering duplicated vertical padding is new territory.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>IE bork!</title>
<style type="text/css">
html, body {
margin:0;
padding:0;
}
#container {
border:1px solid red;
background-color:#CC99CC;
width:800px;
margin:0 auto;
padding-top:100px;
}
#sidebar {
float:left;
display:inline;
width:200px;
border:1px solid blue;
background-color:#00CCFF;
}
#content {
float:right;
display:inline;
width:510px;
border:1px solid green;
background-color:#66CC99;
}
.clear {
clear:both;
/* height:0px; <<< setting height seems to be the only thing that makes this work as expected?!? */
background-color:#CCCCCC; /* bg color here is just for debugging */
}
</style>
</head>
<body>
<div id="container">
<div id="sidebar">I am the sidebar</div>
<div id="content">I am the content</div>
<div class="clear"><!-- clear! --></div>
</div>
<p>There should be 100px of space above the two floats, but <em>no</em> space below them...</p>
</body>
</html>
P.S., After much trial and error, I finally found a fix for the issue in IE. The solution involved explicitly setting a height on my "clear" div, which is currently commented out to showcase the bug. It's frustrating how much time I spent troubleshooting this!
Thank you!