Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I reduce the vertical space between list items in an unordered list?

Tags:

html

css

I've got a very simple html unordered list:

<ul> <li>First</li> <li>Second</li> </ul> 

The problem is that the default styling for such a list in firefox leaves a lot of space between each list item - about the same as between paragraphs in a <p> tag. My google-fu is proving uncharacteristically useless today - how do I reduce that vertical space? I assume there's a css element I can apply to the <ul> tag, but I can't seem to find anything.

(This is going in the side navigation element of a page so it needs to be as compact as possible.)

like image 222
Electrons_Ahoy Avatar asked Aug 11 '09 21:08

Electrons_Ahoy


People also ask

How do I reduce vertical space in HTML?

HTML allows one to reduce vertical space, using something like p { margin-top: -20px; } or such as shown in number of places on the net. For example how-to-reduce-the-space-between-p-tags.

How do I reduce the space between bullets in HTML?

The best way is using the HTML <span> element. Put the content into a <span>, and set the CSS position property to “relative” and also, add the left property to control the space.

How do I reduce horizontal space between Li in HTML?

You need to use display:block and float:left on the li s to remove the space. When they're inline the browser treats them as words, and so leaves space in between.


1 Answers

Further to all the other answers, it might be worth setting line-height: 1em; to reduce the leading space of each line. Of course, the padding-top, padding-bottom, margin-top and margin-bottom are all the most-likely culprits.

like image 106
David Thomas Avatar answered Oct 20 '22 09:10

David Thomas