views:

84

answers:

3

I am trying to use unordered lists as columns something setup like the following:

<ul>
<li>word 1</li>
<li>word 1</li>
<li>word 1</li>
<li>word 1</li>
<li>word 1</li>
</ul>
 <ul>
 <li>word 2</li>
 <li>word 2</li>
 <li>word 2</li>
 <li>word 2</li>
 <li>word 2</li>
 </ul>

What would I need to do as far as css these to lineup side by side as vertical lists with no bullets. I'm sure I'm missing something simple but I can't seem to figure it out. I specifically need this to work in IE7.

Thanks in advance, Ben

+5  A: 

Here's the really short answer:

ul {
  float: left;
  list-style-type: none;
}

Here's the slightly longer explanation:

  • The float part tells your lists to move together "on the same line". You might want to add a width property to the ul elements as well, in order to get equally distributed columns.

  • The list-style-type property simply turns off your bullets. Most likely, you will now have empty space where the bullets used to be. This can be removed by overriding maring and padding - eg. set them both to zero.

You might also want to add a clear: left property on whatever element is following the lists.

Jørn Schou-Rode
`list-type-style` is something I've not seen before, is it a synonym for `list-style-type` or a typo?
David Thomas
@ricebowl: That would be the result of me being tired. It's fixed now. Thanks for pointing it out :)
Jørn Schou-Rode
Ah, a caffeine-underflow error. =)
David Thomas
A: 
<div class="wrapper">
<ul>
<li>word 1</li>
<li>word 1</li>
<li>word 1</li>
<li>word 1</li>
<li>word 1</li>
</ul>
 <ul>
 <li>word 2</li>
 <li>word 2</li>
 <li>word 2</li>
 <li>word 2</li>
 <li>word 2</li>
 </ul>
<div class="clear"></div>
</div>

<style type="text/css">
ul {width: 40%; float: left;list-style-type: none;}
ul li {list-style-type: none;}
.clear {clear:both;font-size:0px;line-height:0px;height:0px;}
</style>

Something along those lines... keep in mind that this will look quite a bit more "standard" between browsers if you have a decent CSS reset block. I recommend Blueprint.

Plan B
A: 

Here's an example:

<div id="menucontainer">
  <ul>
    <li>w1</li>
    <li>w2</li>
  </ul>
</div>

Css:

#menucontainer ul {
  list-style-type: none;
}

#menucontainer ul li {
  display: inline;
  padding: 0.1em;
}
Carra