I want to style the last/second .heading
.
<ul>
<li class="heading">Hello world</li>
<li>Hello world</li>
<li>Hello world</li>
<li class="heading">Hello world</li>
<li>Hello world</li>
</ul>
Neither
ul li.heading:last-child {
background: black;
}
nor
ul li.heading:nth-child(2) {
background: black;
}
works for me. Why, and how can I apply styles to that <li>
? It seems pseudo-class selectors doesn't work with class selectors. Which is weird since I could've sworn I'd used it before.
Update: Oops, totally forgot the jsfiddle.