I have a table with multiple rows, where the first row serves as the header and is styled differently using CSS.
Now, I am looking to change the background color of all the remaining rows within that table on mouseover using CSS. However, the header row's background should remain unchanged.
HTML
<table border="1" width="100%" id="table1">
<tr class="headerStyle">
<td>Sl.No</td>
<td>Name</td>
<td>Code</td>
</tr>
<tr>
<td>1</td>
<td>Name1</td>
<td>Code1</td>
</tr>
<tr>
<td>2</td>
<td>Name2</td>
<td>Code2</td>
</tr>
<tr>
<td>3</td>
<td>Name3</td>
<td>Code3</td>
</tr>
</table>
CSS
.headerStyle {
color: #ffffff;
font-size: 13px;
text-align: center;
font-weight: 500;
background-color: #07889b;
}
.headerStyle + tr:hover {
background-color: #bedcfc;
}
I have tried various suggestions from sources like Stack Overflow without success.
Although I attempted the above solution, it only changes the first row's background color.
Is there a way to accomplish this purely through CSS? Thank you in advance.