Reputation:
I just notice that if I set "tr" element color to red, then "td" border color is also set to red. Is it a browser's bug?
https://jsfiddle.net/tbgggu62/3/
<table>
<tbody>
<tr style="color: red;">
<td >A</td>
<td>B</td>
</tr>
<tr class="spaceUnder">
<td>C</td>
<td>D</td>
</tr>
<tr>
<td>E</td>
<td>F</td>
</tr>
</tbody>
</table>
Thanks.
Upvotes: 1
Views: 2602
Reputation: 11
As Joseph Marikle said the color is inherited by default. Since it was set at the tr level everything under it will also be set to red unless you don't want it to be.
to leave the text red, but change the border color use this:
td {
border-style: solid;
border-width: 1px;
border-color:black;
}
or use shorthand(it saves space)
td {
border:solid 1px black;
}
to have the border red, but change the text color in the first row do this:
td {
border:solid 1px;
}
tr:nth-child(1) td{
color:black;
border: solid 1px red;
}
Upvotes: 0
Reputation: 78540
It is not a bug. You have set the color for the tr
to red
, the td
inherits color
from its parent and is therefore also red
. Lastly, you have set the border-style
and border-width
of the td
, but you did not set the border-color
. border-color
defaults to currentcolor
, which is the text color of the element: in this case red
.
Through a series of inheritance and default values, it is working as intended.
Upvotes: 5