tags:

views:

10

answers:

2

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

A: 

Try setting padding and margin to 0:

#ul_id li{
  padding:0px;
  margin:0px;
}
Sarfraz
+1  A: 

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.
moontear
Also see this stackoverflow post: http://stackoverflow.com/questions/241512/best-way-to-manage-whitespace-between-inline-list-items
moontear
float:left is the one I was looking for. Thanks... no need to display:block though.
Tom