I would like to have one column in a table have a blue gradient background from top to bottom. As in extending over multiple rows, ten precisely. Essentially like this one but for a column instead of row:
https://codepen.io/warkentien2/pen/JxxXvr
<table>
<tr> <td></td> <td class = "gradient_column"></td> <td></td> </tr>
<tr> <td></td> <td class = "gradient_column"></td> <td></td> </tr>
<tr> <td></td> <td class = "gradient_column"></td> <td></td> </tr>
</table>
3
Answers
You can apply a
rowspan
on the column you want to have a gradient of, having the value equal to the number of rows and then have atable
inside thistd
with as many rows as the outer table and apply your gradient styling on this inner table:Since you cannot apply a background to a column and since you need one uninterrupted gradient over all cells in that column, you could apply the gradient background to the whole table and define the background for all cells except the the desired ones as white (or any other color you want):
In the example below I cholse the last column for the gradient background, but it could be done with any one or also several ones using
nth-child
ornth-of-type
in the selectors. Additionally I applied transparent borders to those "gradient cells" since I used grey borders for the whole table.Well, if you are using a table you can use the
colgroup
andcol
tags to describe the columns, and you can apply the styling there to affect the whole column.To make it continuous you should collapse the borders, which might limit other styling options you might want on the table (or force you to be a little more creative to achieve them)