html - Select all but last list-element -


i have list of tags want display horizontally. each <li>, last one, want add , after item.

now, can of course:

ul.tags {     list-style: none; }  ul.tags > li {     display: inline; }  ul.tags > li:after {     content: ", "; }  ul.tags > li:last-of-type:after {     content: ""; } 

now thought combining last 2 rules, like:

ul.tags > li:not(ul.tags > li:last-of-type):after {     content: ", "; } 

but not work. how can select but last <li>?

all need :last-of-type within :not (like in below snippet). :not accepts simple selectors argument.

below specifications simple selectors:

a simple selector either type selector, universal selector, attribute selector, class selector, id selector, or pseudo-class.

ul.tags > li:not(:last-of-type):after {    content: ", ";  }  ul.tags {    list-style: none;  }  ul.tags > li {    display: inline;  }
<ul class='tags'>    <li>1</li>    <li>2</li>    <li>3</li>    <li>4</li>  </ul>


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -