4

How can I make unordered list (ul/li) not begin on a new line for each LI. User wants the bullet, but to save space, not show bullet on each line.

Yes I know it is strange request.

7 Answers 7

5

You could use:

li { display: inline; }

To remove the way that li's normally go on a new line. People have used that method in additional to style: none; for CSS based horizontal navigation for quite a while now.

Sign up to request clarification or add additional context in comments.

1 Comment

Very true both of you, thirtydot's answer is what you're after, I forgot to read fully! sorry :(
2

Try this:

li {
    float: left;
    margin: 0 15px
}

Comments

1

A better method, provided you don't need <IE7 support, would be: http://jsfiddle.net/csswizardry/8czmt/

It's better because display:inline is a lot more predictable than float:left, which would require you to use a clearfix or similar on the <ul>.

H

Comments

0

With float:left; and a bit of margin/padding tweaking

http://jsfiddle.net/mrmikemccabe/TZqMy/

Comments

0

you can also use:

li {float:left}

or

.ul_class_name li {float : left}

(in case you have more than one ul and want to do this only to this one.

Remember you have to make

<div class="clear"></div>

after closing the ul if you choose this

1 Comment

yeah and you have to tweak the left padding/margins obviously
0

This will do it:

ul { overflow:hidden; list-style-type:none } //clear internal float and remove bullet
li { margin:0 5px; float:left; width:auto; } //ie6 additions are needed as width auto is problemativ

<ul>
  <li>content</li>
  <li>content</li>
  <li>content</li>
</ul>

I prefer using floats, but of course you can use display:inline as well...

2 Comments

The default value of width is auto, you never need to specify it unless you're overriding something else.
yep just making it clear that for IE6 auto widths wont render correctly.
0

In my case all I needed was the below code:

style='margin-top: 1px;'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.