/ Published in: CSS
Separates an html list of words with a comma using CSS.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Comma separated list</title> <style> #tags ul li{ display:block; float:left; _display:inline; _float:none; } #tags ul li::after{ content:", "; white-space:pre; } #tags ul li:first-child::before{ content:""; } #tags ul li:last-child::before{ content:"& "; white-space:pre; } #tags ul li:last-child::after{ content:""; } #tags ul + *{ clear:left; } </style> </head> <body> <div id="tags"> <ul> <li>t-shirt (1)</li> <li>design (1)</li> <li>etiquette (1)</li> </ul> </div> </body> </html>