This is similar to this question, however I want to know if I can do same with css only.
My code:
.a:last-of-type {
background: #ff0000;
}
<h1>This is a heading</h1>
<p class="a">The first paragraph.</p>
<p class="a">The second paragraph.</p>
<p class="a">The third paragraph.</p>
<p class="a">Last of class a, please select.</p>
<p class="b">The fifth paragraph.</p>
So, all I want to do is select the element with the text 'Last of class a, please select', i.e. the last element with class a.
This example has a fixed number of elements, but where I want to use it, the exact number will be set at runtime.