How to add horizontal list items with CSS?

Spread the love

To add horizontal list items with CSS, we display the li elements as inline block elements.

For instance, we write

<ul>
  <li><a href="#">some item</a></li>
  <li><a href="#">another item</a></li>
</ul>

to add a ul with some li elements.

Then we write

ul > li {
  display: inline-block;
}

to make the li’s display as inline block elements to make them display horizontally.

Leave a Reply

Your email address will not be published. Required fields are marked *