0

I'm running into a weird issue that I've never noticed before. I have the following code:

<div class="feedback">
  <span> Was this helpful?</span>
  <ul>
    <li>
      <a href="#">Yes</a>
    </li>
    <li>
      <a href="#">No</a>
    </li>
    <li>
      <a href="#">No</a>
    </li>
  </ul>
</div>

Very simple block of code. Ignore the second no, as it's literally only there to give me a third li to help me figure this out. Now, here's the CSS...

div.feedback {
  position: relative;
}
span {
  float: left;
}
li {
  display: inline-block;
  padding: 0;
  margin: 0;
  border-left: 1px solid #000
}

Now, here's what's happening:

border-left

See the extra spacing that's seemingly coming from nowhere? I moved to border-right just to test it, and got even more inconsistent results:

border-right

Now, the 3rd LI has 0 padding and margin, as it should. The other two still have a spare space.

Lastly, the browser comprehends the proper height and width of the li, and attributes no margin or padding to it. According to the browser, the text should be smashed up against the border, as I also expect.

browser no understand

Can someone please explain what this extra 3-5 pixels of spacing is on the right of the text?

  • Could you make a jsfiddle? That would help us fool around with this little demo – thatidiotguy Dec 04 '12 at 20:44
  • I made the JS Fiddle for you guys to fool around with. http://jsfiddle.net/MrXenotype/Z8eCg/ – Felix Guo Dec 04 '12 at 20:45
  • The guy below me beat me to it, but I was thinking of the white space in your code as well. There's an extra space because there is a space between the definition of the `
  • ` elements.
  • – Felix Guo Dec 04 '12 at 20:46