I have a list of elements under the same container. some of them has class A, other has class B. I'm looking for a CSS selector to select the first A element in a group of A and the first B element in a group of B.
Example:
<style>
.A { background: red; }
.B { background: blue; }
</style>
<ul class="list">
<li class="item A">AAA</li><!-- I want to select this -->
<li class="item A">aaa</li>
<li class="item A">aaa</li>
<li class="item B">BBB</li><!-- I want to select this -->
<li class="item B">bbb</li>
<li class="item B">bbb</li>
<li class="item A">AAA</li><!-- I want to select this -->
<li class="item A">aaa</li>
<li class="item A">aaa</li>
</ul>
Notice that using the pseudo selector :first-of-type
will not work, becuase it will select the first element of type without group relation.
Also trying to use :first-child
will not work ether, since it will select only the first A element, and will not select the first B element, also it will not select the first A element in the 2nd group.
Note
I don't believe this is a duplicate of "CSS selector for first element with class".