How to make a HTML list appear horizontally instead of vertically using CSS only?

M. A. Kishawy picture M. A. Kishawy · Jan 27, 2010 · Viewed 147.6k times · Source

I need this because I want to make a menu (which is made from a HTML list) appear horizontally.

I prefer not to use absolute positioning since it might become messy when I start changing the layout of the page.

I would like also to remove the indenting of the sub-lists. Is it possible?

Answer

Ravia picture Ravia · Jan 27, 2010

You will have to use something like below

#menu ul{
  list-style: none;
}
#menu li{
  display: inline;
}
	
<div id="menu">
  <ul>
    <li>First menu item</li>
    <li>Second menu item</li>
    <li>Third menu item</li>
  </ul>
</div>