Below is the CSS code for my table:
table.show-my-request-table {
border: 1px solid black;
margin-left:auto;
margin-right:auto;
border-collapse: collapse;
}
tr.show-my-request-table-header{
border: 1px solid black;
}
tr.show-my-request-table{
border: 1px solid black;
}
tr.show-my-request-table:hover{
background-color: #D3D3D3;
}
And this is the HTML code for the table:
<table class="show-my-request-table center">
<tr class="show-my-request-table-header">
<th>Date</th>
<th>Priority</th>
<th>Question</th>
</tr>
<tr >
<td class="show-my-request-table"> 11.8.2016 15:27:13
</td>
<td>
<img src="/resources/img/priority-flag/priority-LOW-icon.png" class="priority-icon">
</td>
<td>
</td>
</tr>
<tr >
<td class="show-my-request-table">
11.8.2016 14:45:41
</td>
<td>
<img src="/resources/img/priority-flag/priority-LOW-icon.png" class="priority-icon">
</td>
<td>
Jak se máš?
</td>
</tr>
</table>
I am trying to set a red background for the first td
tag.
The problem I am facing is that the styling affects all tables, not just one specific table.
When I use the following CSS:
td:first-child {
background-color: #ff0000;
}
it applies to all tables, not just the targeted one.
I have also tried the following code, which doesn't seem to work either:
table.show-my-request-table > td:first-child {
background-color: #ff0000;
}
Could you please help me understand why this code is not working as intended and provide a solution?