168

Possible Duplicate:
Unwanted margin in inline-block list items
How to remove “Invisible space” from HTML

Why do the inline-block list items have a space in them? No matter how I make my list items into a menu, I always get spaces.

li {
  border: 1px solid black;
  display: inline-block;
  height: 25px;
  list-style-type: none;
  text-align: center;
  width: 50px;
}
ul {
  padding: 0;
}
<ul>
    <li>One</li>
    <li>Two</li>
    <li>Three</li>
</ul>
Tyler Crompton
  • 11,740
  • 12
  • 59
  • 91
  • 1
    When you say space "in them" what does that mean. The space char is between the
  • tags? FYI: The html you have here is not valid. You don't have a
      or
        . – Shiv Kumar Mar 10 '11 at 07:14
    • 1
      where does it have a space? Add a screenshot or a demo please – JohnP Mar 10 '11 at 07:14
    • Do you mean horizontal space between each element. If you do then you can reset the margin and padding to 0 in your menu#headerMenu li definition and also remove the width 100px; – Simon H Mar 10 '11 at 07:14
    • Yes, the space character is between the
    • tags. About the
        and
        thing, thanks. I forgot the the tag has been deprecated. Anyway, the spaces still applies to the
      1. tag.
    • – Tyler Crompton Mar 10 '11 at 07:20
    • I updated the code to get rid of all the unnecessary code to help you see what's going on. – Tyler Crompton Mar 10 '11 at 07:28
    • Found a solution here, explaining in a good way how to remove it.. http://www.ultimatewebtips.com/remove-space-between-li-with-display-inline-block/ – Joakim Ling Sep 06 '12 at 10:02