In this BlueSky post the user shows some crazy CSS that allows for dynamic table highlighting. The CSS included in that post was this:
td:has(~ td:hover), /* previous sibling cells */
table:has(td:nth-of-type(3):hover) /* column cells */
tr:not(:first-of-type):has(~ tr:hover)
td:nth-of-type(3) {
background: var(--highlighted);
}
This CSS should highlight a row up to the cell that is hovered and it should also highlight a column up to the cell that is hovered.
After removing the :not(:first-of-type)
because I have proper table headers, the CSS seems to do the highlighting well for any row but only works for the 3rd column, as the example table below shows.
I'm not sure yet if there's a way to not hardcode the 3 in the CSS to work for any column independently or if I'd have to write selectors explicitly for all columns.
# | English | Portuguese | French | German | Italian |
---|---|---|---|---|---|
1 | January | Janeiro | Janvier | Januar | Gennaio |
2 | February | Fevereiro | Février | Februar | Febbraio |
3 | March | Março | Mars | März | Marzo |
4 | April | Abril | Avril | April | Aprile |
5 | May | Maio | Mai | Mai | Maggio |
6 | June | Junho | Juin | Juni | Giugno |
7 | July | Julho | Juillet | Juli | Luglio |
8 | August | Agosto | Août | August | Agosto |
9 | September | Setembro | Septembre | September | Settembre |
10 | October | Outubro | Octobre | Oktober | Ottobre |
11 | November | Novembro | Novembre | November | Novembre |
12 | December | Dezembro | Décembre | Dezember | Dicembre |