0

If I code inline list items on separate lines of code there is a space inserted between them.

Is there a way to prevent this from happening with coding all of the list items on the same line of code?

<li>123</li>
<li>456</li>

creates the following which I don't want

123 456

<li>123</li><li>456</li>

creates the following which i do want

123456

thanks

Tom
  • 12,776
  • 48
  • 145
  • 240

2 Answers2

1

I'm assuming you use CSS display: inline to inline your list items?

display: inline does exactly that: it converts your new line in your source code to a space character. You have two options now:

  1. Either you write all your <li> items in one line, then display: inline will actually make your list items behave like you want (no space in-between) - I have set up an example for you here: http://www.jsfiddle.net/NxrQ9/.
  2. Or instead of inlining your elements you just go with display:block and float: left.
Dennis G
  • 21,405
  • 19
  • 96
  • 133
  • Also see this stackoverflow post: http://stackoverflow.com/questions/241512/best-way-to-manage-whitespace-between-inline-list-items – Dennis G Oct 12 '10 at 14:41
  • float:left is the one I was looking for. Thanks... no need to display:block though. – Tom Oct 12 '10 at 14:56
0

Try setting padding and margin to 0:

#ul_id li{
  padding:0px;
  margin:0px;
}
Sarfraz
  • 377,238
  • 77
  • 533
  • 578