I need to change the color of text 5
to red.
This doesn't work. What is the possible resolution to this problem?
Note: This is a small representation of the actual problem. So the placement of children is not fixed, nor their numbers.
#parent>.child:last-of-type {
color: red;
}
<div id="parent">
<span class="child">1</span><br>
<a>2</a><br>
<span class="child">3</span><br>
<a>4</a><br>
<span class="child">5</span><br>
<span>6</span>
</div>