Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to style a horizontal list with bullets between items using CSS?

Tags:

html

css

I'm not sure how to build a horizontal list that looks like this:

Centered list with bullets between items

Here are the rules:

  • There is an unlimited number of items in the list.
  • Each item should be on a single line and not wrap to a 2nd line.
  • Multiple items can be on a single line if there is space for them to fit
  • If multiple items are on a single line, they should be separated by a divider
  • The divider looks like a bullet, but it could be an image
  • Need it to work in modern browsers as well as IE8+

The thing I'm not sure how to do is to make the bullets appear only between items, and not also before or after each row of items.

like image 755
Tauren Avatar asked Mar 09 '13 01:03

Tauren


People also ask

How do I style a horizontal list in CSS?

If you want to make this navigational unordered list horizontal, you have basically two options: Make the list items inline instead of the default block. .li { display: inline; } This will not force breaks after the list items and they will line up horizontally as far as they are able. Float the list items.

How do I make bullet points horizontal in HTML?

By default, the HTML <ul> list will be rendered vertically with one list item on top of another. When you need to create a list that expands horizontally, you need to add the display:inline style to the <li> elements of the list.

How would you display a list item with a different bullet?

To create unordered list in HTML, use the <ul> tag. The unordered list starts with the <ul> tag. The list item starts with the <li> tag and will be marked as disc, square, circle, etc. The default is bullets, which is small black circles.

How do I put space between list items in CSS?

To create space between list bullets and text in HTML, use CSS padding property. Left padding padding-left is to be added to <ul> tag list item i.e. <li> tag. Through this, padding gets added, which will create space between list bullets and text in HTML.


1 Answers

For those of you who don't have to worry about IE8, this is as simple as:

ul li { list-style: none; display: inline; } ul li:after { content: " \00b7"; } ul li:last-child:after { content: none; } 
like image 54
JavaThunderFromDownunder Avatar answered Oct 11 '22 12:10

JavaThunderFromDownunder