/ Published in: CSS

Displays HTML list as a gramatically correct English sentence. \r\n\r\nFor example\r\n\r\n<ul class=\"commaList\">\r\n <li>one</li>\r\n <li>two</li>\r\n <li>three</li>\r\n <li>four</li>\r\n</ul>\r\n\r\nWould be displayed as: One, two, three and four.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/* display ordered list as comma list */ ul.commaList li:after{ content: ','; padding-right: 5px; } ul.commaList li:first-child { text-transform: capitalize; } ul.commaList li:nth-last-child(2):after { content: ''; padding-right: 5px; } ul.commaList li:last-child:after { content: '.'; clear: both; } ul.commaList li:last-child:before { content: 'and '; padding-right: 0; } ul.commaList li:only-of-type:before { content: ''; padding: 0; }
Comments
