Czy można użyć selektora CSS3, :first-of-typeaby wybrać pierwszy element o danej nazwie klasy? Mój test się nie powiódł, więc myślę, że nie?
Kod ( http://jsfiddle.net/YWY4L/ ):
p:first-of-type {color:blue}
p.myclass1:first-of-type {color:red}
.myclass2:first-of-type {color:green}
<div>
<div>This text should appear as normal</div>
<p>This text should be blue.</p>
<p class="myclass1">This text should appear red.</p>
<p class="myclass2">This text should appear green.</p>
</div>
.myclass1Selektor wybierze każdy element.myclass1. Selektor.myclass1 ~ .myclass1używa ogólnego kombinatora rodzeństwa, aby wybrać każdy element z klasą,.myclass1która jest kolejnym rodzeństwem elementu z klasą.myclass1. Jest to wyjaśnione tutaj niezwykle szczegółowo .