I have tried everything I can think of in css in order to get a background color to span an entire table row (
Removing the borders should make the background color paint without any gaps between the cells. If you look carefully at this jsFiddle, you should see that the light blue color stretches across the row with no white gaps.
If all else fails, try this:
table { border-collapse: collapse; }
Try this:
.rowhighlight > td { background: green;}
tr.rowhighlight td, tr.rowhighlight th{
background-color:#f0f8ff;
}
Have you tried setting the spacing to zero?
/*alternating row*/
table, tr, td, th {margin:0;border:0;padding:0;spacing:0;}
tr.rowhighlight {background-color:#f0f8ff;margin:0;border:0;padding:0;spacing:0;}
table{border-collapse:collapse;}
I prefer to use border-spacing
as it allows more flexibility. For instance, you could do
table {
border-spacing: 0 2px;
}
Which would only collapse the vertical borders and leave the horizontal ones in tact, which is what it sounds like the OP was actually looking for.
Note that border-spacing: 0
is not the same as border-collapse: collapse
. You will need to use the latter if you want to add your own border to a tr
as seen here.