Skip to content

Instantly share code, notes, and snippets.

@jedsundwall
Created September 18, 2010 23:00
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jedsundwall/586144 to your computer and use it in GitHub Desktop.
Save jedsundwall/586144 to your computer and use it in GitHub Desktop.
CSS to add commas to items in an unordered list without leaving a comma hanging at the end of the list
ul.tags {
display: inline;
margin: 0;
padding: 0;
}
ul.tags li {
display: inline;
list-style: none;
margin: 0;
padding: 0;
}
ul.tags li:after {
content: ", ";
color: #aaa;
}
ul.tags li:last-child:after {
content: "";
}
@narzac
Copy link

narzac commented Jul 24, 2013

Thanks Jed, that is exactly what i need :)

@prabhjoban
Copy link

Thanks a lot Jed.. :)

@i5ar
Copy link

i5ar commented Dec 20, 2014

Thanks!

@ziomio
Copy link

ziomio commented Nov 11, 2015

thanks :)

Copy link

ghost commented Apr 13, 2017

great

@Plastiquewind
Copy link

You saved my day, dude! Thank you so much!

@jedsundwall
Copy link
Author

I had no idea people were commenting on this! I'm so glad this helped you all! <3

@volodymyrbalytskyy
Copy link

Or even like this:

ul.tags li:not(:first-child):not(:last-child):after {
  content: ", ";
  color: #aaa;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment