How to style unordered lists in CSS as comma separated text

后端 未结 6 2054
时光说笑
时光说笑 2020-12-08 06:10

I’m looking for a way to style an unordered list in XHTML with CSS such that it is rendered inline and the list items are separated by commas.

For example, the follo

6条回答
  •  悲哀的现实
    2020-12-08 06:35

    This is the way that the guys at A List Apart recommend in their article “Taming Lists":

    #taglist ul li:after {
        content: ",";
    }
    
    #taglist ul li.last:after {
        content: "";
    }
    

    This requires having the last item in your list tagged with a class attribute value of “last”:

    • apple
    • orange
    • banana

提交回复
热议问题