The better I get at css (and I am getting better) I really start to understand designers hatred for IE. I guess I always knew it on some level but when you are really trying to write clean code it starts to upset you that you have to hunt down IE6 specific bugs. My advise to everyone working with css is to get your layout/design working in a standards compliant browser and then double back to find out what bugs you need to fix. The bug I came across today (I have before but this is a great fix) is the IE Whitespace bug.
I was trying to create a block level list elements for a navigation like flow. When you use the code below and check the output in FireFox everything is exactly how you want it. In IE though there is extra space between elements. Here is the code and what it looks like in both browsers. The one on the left is FF and the right is IE6.
2<head>
3 <title>Lists Example</title>
4 <style>
5 #navigation {
6 width:200px;
7 }
8 h3 {
9 margin:0px;
10 padding:0px;
11 border-bottom:1px dotted #272727;
12 }
13 ul {
14 margin:0px;
15 padding:0px;
16 list-style-type:none;
17 }
18 li a {
19 color: #759398;
20 text-decoration: none;
21 padding-top: 4px;
22 padding-right: 0px;
23 padding-bottom: 4px;
24 padding-left: 2px;
25 display: block;
26 border-bottom:1px dotted #272727;
27 }
28 li a:hover {
29 text-decoration: none;
30 background-color: #132022;
31 color: #ffffff;
32 }
33 </style>
34</head>
35<body>
36
37 <div id="navigation">
38 <h3>Navigation</h3>
39 <ul>
40 <li><a href="##">Menu Item 1</a></li>
41 <li><a href="##">Menu Item 2</a></li>
42 <li><a href="##">Menu Item 3</a></li>
43 <li><a href="##">Menu Item 4</a></li>
44 <li><a href="##">Menu Item 5</a></li>
45 <li><a href="##">Menu Item 6</a></li>
46 <li><a href="##">Menu Item 7</a></li>
47 <li><a href="##">Menu Item 8</a></li>
48 <li><a href="##">Menu Item 9</a></li>
49 <li><a href="##">Menu Item 10</a></li>
50 </ul>
51 </div>
52
53</body>
54</html>
One solution to the problem I found that I really like was hicksdesign.co.uk. After reading through the comments though some users pointed out that the css may not validate so I ended up going with a solution from the comments. Placing the following code in your css will fix the problem and the css will validate. The final outlook looks good in all the browsers that I tested.
2* html ul li a {
3 height:1em;
4}
5</style>

#1 by joshua cyr on 12/27/07 - 1:32 PM
ul, li, li a { vertical-align:bottom;}
http://www.usefulconcept.com/index.cfm/2007/12/3/I...
#2 by Dan Vega on 12/27/07 - 1:35 PM
That solution makes sense as well. I believe there are many solutions out there. The ultimate solution will hopefully come in the form of a standards compliant IE :)
#3 by John on 12/27/07 - 3:11 PM
I do the opposite for css, I build for IE6 first. My server reports show most people (not designers) still use IE6 or 7. I get those dialed in perfect, and then hack for standards compliancy. After years of the opposite, I tried it, and it took me half the time. It's worth giving it a go sometime.
Great post, and great hack. I just ran across your site and I am liking what I have found.
#4 by Dan Vega on 12/27/07 - 3:34 PM
Thanks for the feedback. I guess you really could take it on a case by case basis. For example when working on my site analytics tells me the 54% of my visitors are firefox users while of the 38% that are IE users use 7.0. Everyone has their way of doing it but I just feel that if you create for standards first then you actually learn what code does what! Thanks for reading!
#5 by Christian Ready on 12/27/07 - 6:49 PM
#6 by Matt Leichty on 1/17/08 - 7:42 PM
ul#myelement li {
vertical-align: bottom; zoom: 1;
}
Dropping either declaration caused a rendering problem, albeit not the same problem. Doing both fixed it. Why? Who TF knows.
#7 by TWD on 2/13/08 - 5:04 PM
#8 by Joel Pittet on 3/25/08 - 8:34 PM
#9 by El John on 3/28/08 - 1:38 AM
#10 by Chris M on 5/12/08 - 4:39 PM
* html ul li a {
height:1em;
}
</style>
Awesome fix, thank you so much!!
#11 by Nils Hendriks on 9/2/08 - 9:13 PM
Note that 1% also works, just like 1 em;
#12 by Jon Dear on 2/27/09 - 8:00 PM
This worked on ie6: * html ul li a {height:1em;}
This worked on ie7: ul, li, li a {vertical-align: bottom; zoom: 1;}
#13 by Meir on 3/8/09 - 8:39 AM
#14 by Dimitris on 7/23/10 - 8:33 AM
#15 by Adam Meyer on 9/20/10 - 7:20 PM
#16 by Jon on 2/15/12 - 5:16 PM
If there's any help you can give me I would really appreciate it!
Thanks
http://ReverseWineSnob.com
#17 by Jon on 2/15/12 - 10:52 PM
<script type='text/javascript'>
window.setTimeout(function() {
document.body.className = document.body.className.replace('loading', '');
}, 10);
</script>
So far no negative repercussions but we'll see...not even sure what this code does :)