views:

284

answers:

2

To make lists horizontal and hide default bullets, is it necessary to give {display:inline} and {float:left} both to the <li> tags or anyone of these alone is enough?

<ul>
<li><a href="#">First item</a></li>
<li><a href="#">item 2</a></li>
<li><a href="#">item 3</a></li>
<li><a href="#">item 4</a></li>
<li><a href="#">Last item</a></li>
</ul>

How to make cross browser (including IE6 and FF2) , pixel perfect horizontal list without bullet in best way?

What is best and short method?

ul {}
li {}
a  {}
+3  A: 

No, either one alone is enough. You could even use inline-block if you like, although it doesn't have very good support in FF2. Hiding bullets is done with list-style:none;

You could setup a simple test quickly to check these:

#one, #two, #three { list-style:none }
#one li            { float:left }
#two li            { display:inline }
#three li          { display:inline-block }
<ul id="one">
  <li>Float left</li> 
  <li>In this example</li>
</ul>
<div style="clear:both"></div>
<ul id="two">
  <li>Display inline</li>
  <li>In this example</li>
</ul>
<div style="clear:both"></div>
<ul id="three">
  <li>Inline-block</li>
  <li>In this example</li>
</ul>

See how they render: http://jsbin.com/opiqu3/

Jonathan Sampson
to make list horizontal in all browser {display:inline} is enough
metal-gear-solid
Is that a statement, or a question? My first sentence ("...either one alone is enough") states the same thing.
Jonathan Sampson
it's statement. u mean answer of @sarfraz is not correct
metal-gear-solid
I don't see where my post disagrees with Sarfraz's post. Mine preceded his by a minute - so I don't see the contention.
Jonathan Sampson
u said ("...either one alone is enough") and sarfraz said "display:inline is not necessary but float:left is necessary"
metal-gear-solid
@Jitendra: Setup a small list, and try it.
Jonathan Sampson
i've tried see my comments in sarfraz answer
metal-gear-solid
Which method is better to follow? although if we use {display:inline} or { display:inline-block }then don't need to define { list-style:none }
metal-gear-solid
and { display:inline-block } doesn't have all browser support. and is the li { display:inline-block } and li {display:inline} a {display:block} will create same effect?
metal-gear-solid
+1 because ur example is helpful for me
metal-gear-solid
@Jitendra: You're talking about a difference in about a dozen chars. It doesn't matter. Just pick one, and continue with development :)
Jonathan Sampson
@Jonathan Sampson - I run a small web design classes and I have to explain to students which method they should used to make list horizontal
metal-gear-solid
@Jitendra: I've taught a web-design class as well, and I would have no problem telling my students, "It really doesn't matter." :)
Jonathan Sampson
A: 

display:inline is not necessary but float:left is necessary to make it horizontal and like you said about hiding default bullets, then even list-style:none is also necessary.

Sarfraz
but if we use {display:inline} then it align item horizontally as well as hide the bullets without {list-style:none}
metal-gear-solid