panthro panthro - 2 months ago 9
CSS Question

CSS to target last UL when there is two ULs

Ive looked at this SO post.

I'm trying to target the last UL when there is only 2

ul
s, meaning if there is a 3rd
ul
it will not apply.

I've tried:

ul:last-child:nth-last-child(2){


HTML:

<ul>
....
</ul>
<ul>
....
</ul>


But no luck, where am I going wrong?

Answer

Use a combination of last child and second child:

ul:last-child:nth-child(2) { ... }