Skip to content

Instantly share code, notes, and snippets.

@jedsundwall
Created September 18, 2010 23:00
Show Gist options
  • 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: "";
}
@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