Do like this, using the direct child selector >
Note that the direct child selector > is needed if you ever add a second element, which I did as a sample, or else that element'f first span will be selected as well
Sample code update based on an edit of the original question
.month24 { padding-left: 10px; } .info:nth-of-type(2) .price > span:first-child { color: #f40; }
<div class="info"> <span>Plan</span> <div class="price"> <span>95<sup>99</sup></span> <span>dollars</span> </div> </div> <div class="info"> <span>Plan</span> <div class="price"> <span>95<sup>99</sup></span> <span>dollars</span> <div class="month24"> <span>85<sup>99</sup></span> <span>dollars</span> </div> </div> </div> <div class="info"> <span>Plan</span> <div class="price"> <span>95<sup>99</sup></span> <span>dollars</span> </div> </div>
Now, if it's the first span in info, you do like this
.month24 { padding-left: 10px; } .info:nth-of-type(2) > span:first-child { color: #f40; }
<div class="info"> <span>Plan</span> <div class="price"> <span>95<sup>99</sup></span> <span>dollars</span> </div> </div> <div class="info"> <span>Plan</span> <div class="price"> <span>95<sup>99</sup></span> <span>dollars</span> <div class="month24"> <span>85<sup>99</sup></span> <span>dollars</span> </div> </div> </div> <div class="info"> <span>Plan</span> <div class="price"> <span>95<sup>99</sup></span> <span>dollars</span> </div> </div>
.priceis the firstdivinside its parent, so:nth-of-type(2)doesn't match. I don't see the "3 exactly the same divs".>solved your issue (also wrote that under my answer), how come you changed to an answer that doesn't use that?