I need when last child's color is yellow need to add :nth-last-child(2) as RED background color without JavaScript
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
tr th[style='color: yellow;']:nth-child(2) {
background-color: red;
}
<table>
<tr>
<th>Company</th>
<th>Contact</th>
<th class="last" style="color: yellow;">Country</th>
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Maria Anders</td>
<td>Germany</td>
</tr>
</table>