IE6 Adding Extra Space Between Navigation Lists

By Randy Jensen | Aug 23, 2007

So I’m working on a new template for Wordpress and thought I was done…until I checked it in Internet Explorer 6.

I was using an unordered list to do my navigation, which means my CSS code looked something like this

#sidebar ul {
list-style: none;
margin: 0 0 20px 0;
padding: 0;
}
#sidebar ul li {
display: block;
margin:0;
padding:0
}
#sidebar li{
list-style: none;

}
#sidebar ul li a {
color: #046380;
display: block;
text-decoration: none !important;
margin-left: 0px;
padding: 5px;
}
#sidebar ul li a:hover {
color: #efefef !important;
background-color: #046380;
}

And my HTML like this:

<ul><?php wp_get_archives(‘type=monthly’); ?></ul>

Nothing special here, just a regular ul displayed as block and with a different colored background on hover used to display my WP archives.

The problem was that in IE6 some of the lists were displayed correctly and some were getting extra space added for no reason (below).

IE6 adding space in ul lists

After combing through every line of my css code and whitewashing every browser’s stylesheet, I still could not get it to render correctly. Ready for me to save you some time? Simply add one line of code: width: XXpx;

So my new code looked like this:

#sidebar ul li a {
color: #046380;
display: block;
text-decoration: none !important;
margin-left: 0px;
padding: 5px;
width: 228px;
}

It seems that when links are dynamically generated by wordpress, IE chokes on certain ones for unknown reason (other than that is sucks at life).


  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Design Float
  • DZone
  • Ping.fm
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • TwitThis
  • Yahoo! Buzz
Copy the code below to your web site.
x 

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

  • Jason
    Thanks! Did the trick.
  • Hey Dennis,

    Very interesting. It's always a journey when you're developing something and have to check it with IE.

    Thanks for the tip too!
  • hmmm, this same thing happened to my work team on a bunch of sites we develop.

    i spent over an hour trying to get ie6 to not put that extra space in our menu (just a straight ul and li list). i played with the css all that time and nothing worked.

    that is until i noticed there were two menu items stuck together that were ok way down the list.

    i looked at the html and the only difference was that the one that worked had a single space after the link title between the "a" tags. a space right before the closing "a" tag, that is.

    i quickly added a space in each li right before the closing "a" tag and the whole menu snapped into good behavior, just like in firefox and safari.

    imagine that.
blog comments powered by Disqus
© 2009 Randy Jensen Online, - PassionDuo WordPress Theme