In a web page we have a table nested within another table. In our CSS class first-child
is used to give the first row a blue background. How can I prevent this blue background from being inherited by the nested table.
Also please note that I cannot alter the original styles.
Here is the JSFiddle: https://jsfiddle.net/a0muwsk1/
The last CSS block, .Main table table td
, was one attempt at overriding the first-child styling...It did not work.
And here is the same code from the fiddle page:
Html:
<table class="Main">
<tr>
<td>This</td>
<td>is</td>
<td>first</td>
<td>child</td>
</tr>
<tr>
<td>A</td>
<td>Regular</td>
<td>Row</td>
<td>
<table>
<tr>
<td>Nested</td>
<td>first</td>
<td>child</td>
</tr>
<tr>
<td>Nested</td>
<td>Table</td>
<td>Row</td>
</tr>
</table>
</td>
</tr>
</table>
CSS:
.Main table
{
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
}
.Main tr:first-child td
{
background-color: blue;
text-align: center;
border-width: 0px 0px 1px 1px;
font-family: Arial;
font-weight: bold;
color: white;
}
.Main td
{
border: 1px solid black;
text-align: center;
font-family: Arial;
color: black;
}
.Main table table td
{
border: 1px solid black;
text-align: center;
font-family: Arial;
color: black;
}