If a ul has li items with multiple classes, is it possible to get the last item of a specific class using :last-child?
For example, consider following:
<ul class="test">
<li class="one">
<li class="one">
<li class="one">
<li class="two">
<li class="two">
</ul>
I want to add some style to the last li having class “one” (ie. third in the list).
I tried following and it does not work.
ul.test li.one:last-child
That’s not possible yet.
:last-childselects the last child, regardless of the tag name, etc.:last-of-typeselects the last occurrence of a tag. It ignores the class name, etc.Your only option is to add a specific class name to that element, or use JavaScript to add this class name.