CSS Selectors — What you need to know

:first-child

p:first-child {}<div>
<p>targeted</p>
<p>not targeted</p> <div>
<p>targeted</p>
</div>
</div>
p:first-child {}<div>
<i>not targeted</i>
<p>not targeted</p>
<p>not targeted</p>
</div>

:last-child

p:last-child {}<div>
<p>not targeted</p>
<p>targeted</p>
</div>

:nth-child

p:nth-child(2) {}<div>
<p>not targeted</p>
<p>targeted</p>
</div>

:nth-child(an+b)

:nth-last-child

Source: https://www.w3schools.com/css/css_table.asp

:last-of-type

p:last-of-type {}<div>
<p>not targeted</p>
<p>not targeted</p>
<p>targeted</p>
<i>not targeted</i>
</div>

:nth-last-of-type

p:nth-last-of-type(2) {}<div>
<p>not targeted</p>
<p>not targeted</p>
<p>targeted</p>
<p>not targeted</p>
<i>not targeted</i>
</div>