I am faced with the following situation:
<table>
<tr class="header">
<tr class="data1">
<tr class="data2">
<tr class="data3">
<tr class="header">
<tr class="data1">
<tr class="data2">
</table>
My goal is to change the text color of the data
elements under the first header to blue, and the data
elements under the second header to red.
I have attempted different methods using nth-child
and adjacent sibling (+
) selectors, but I have not been successful so far.
tr[class^=data]
selects all the elements I want to target, but I need them divided into two groups based on the headers.
While I do not know the exact number of data
elements, I am aware that there are only 2 header
elements present.
I am restricted from using javascript/jquery in this scenario, therefore I must rely solely on CSS selectors