1
<ul id="main">
  <li class="the-dropdown-link"><a href="#">Main Link</a>
    <ul id="dropdown">
      <li>sdfsdf</li>
      <li>sdfsdf</li>
    </ul>
 </li>
</ul>

ul#main{ margin:0; padding:0; list-style:none; float:right; width:100%;}
ul#main li.the-dropdown-link{float:left; width:140px; }
ul#main ul {position:absolute; display:none; padding:0;list-style:none;}
ul#main a{display:block;height:24px; width:140px;font-size: 14px; font-weight: 500; text-align: center; color: #ffffff; text-transform: uppercase; line-height: 26px;}

With this vertical dropdown menu I get gaps between the <li> in ie7. Doing my research I see that IE7 creates whitespace between </li> and <li>, however i'm generating my list using php and therefore cannot put all the <li> on the same line like everyone recommends.

I tried adding all the list elements into a variable and using:

$first_list = preg_replace('~>\s+<~', '><', $first_list);

to get rid of spaces, then echoing it.

I don't know what to do.

thirtydot
  • 224,678
  • 48
  • 389
  • 349
Adam
  • 8,849
  • 16
  • 67
  • 131
  • PHP won't output line breaks unless you tell it to. There's some places where they're implied (like in a multi-line HEREDOC), but PHP doesn't just slap in a linebreak because you output an end-tag like ``. – Marc B Jun 10 '11 at 19:14
  • can you clarify "i'm generating my list using php and therefore cannot put all the
  • on the same line like everyone recommends."?
  • – Damien Pirsy Jun 10 '11 at 19:14
  • 1
    whitespace *may* be the issue, but not always. Are you using a CSS reset? There may be some default margin or padding on your ul, li, or a elements. – daybreaker Jun 10 '11 at 19:15
  • How do you generate is using php and why can't you put them on the same line? Do you echo LIs while fetching or add them to an array and then print? Can you give the code that generates/echoes LIs? – AR. Jun 10 '11 at 19:15
  • The `line-height` is 2px bigger than the `height`, is it intentional? – joakimdahlstrom Jun 10 '11 at 19:17