I have a dynamic html table which grows and shrinks based on certain parameters. I have to apply a certain styling to a column which has it's title as YTD.
Earlier when the table was static and I knew the position of the YTD column I was using the below css to style it
.DashboardTable tr td:nth-child(5) {
background-color: #0091D5;
color: white;
}
Since I knew it is the 5th column that I have to style. But now that YTD column can move to 8 or 10 etc positions based on parameters. So I was wondering if there is a way in css where I can target based on the column header(th) so instead of 5 it would say something like below and locate the th with text YTD and apply the style.
.DashboardTable tr td:nth-child("YTD") {
background-color: #0091D5;
color: white;
}
Please let me know if this is possible
Thanks