Experiment-based explanation:
It turns out that when the table borders have the collapsed attribute, the <tr>
's and <td>
' s share the same borders. Therefore, there is no way to display the border of <tr>
at the same time as <td>
... but that's not the whole story.
There is a rule for the border defined in the style of <tr>
to be used, rather than the one defined in the <td>
style.
Experimentally, I noticed that thicker edges have priority. So if the thickest border is in <tr>
, this is the one that will be used. If both have the same thickness, the border set to <td>
will be used.
- 3 pixels (highest priority)
- 2 pixels
- 1 pixel (lower priority)
Using separate units also does not seem to affect ... what matters is the calculated actual measure. If 0.1em results in 2 pixels, then it will have more priority than the 1px border.
Different styles also have different priorities. In Chrome and Firefox the following priority queue is worth:
- hidden (highest priority)
- double
- solid
- dashed
- dotted (lower priority)
Q: I'm ignoring all 3D border styles
The order of styles, or put !important
in style has no effect.
How to solve the problem?
To solve the original problem with a 1 pixel border, we can use a hack :
use the double style with 1px in <tr>
, and a solid style with 1px in <td>
, making the style set to <td>
finally appear.
tr:hover {
border: 1px double red;
}
td {
border: 1px solid gray;
}