The pseudo-class :last-child sets the style for the last element of its parent.
This means that it works only on the last element, from all child elements, and not on the last element for a class or some other attribute.
In this case, it is better to use another pseudo-class :nth-child()
#a span:nth-child(4) /* отсчет от одного, а не от нуля! */
Example
span { display: block; margin: 10px; font-size: 25px; } #a span:nth-child(4) { color: red; }
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>JS Bin</title> </head> <body> <div id="a"> <span class="c1">1...</span> <span class="c1">2...</span> <span class="c2">3...</span> <span class="c2">4...</span> <span class="c1">5...</span> </div> </body> </html>