News for hackers. Stuff that matters.
Re:How to make a table row a link (2020) by stevesunderland on Wednesday September 11, 2024 @09:09PM (#41516693)
Thanks for the tip! That will save me quite a few keystrokes :)

I don't see any issues selecting the text?

Re:How to make a table row a link (2020) by extra88 on Thursday September 12, 2024 @05:08PM (#41525589)
Your 'pen has `td { position: relative; }` so the link's pseudo-element is not actually covering the row, the row only gets the visual styling that makes it appear clickable.

If you remove the positioning from the `td` and add `tr { position: relative; }` then you'll find you can activate the link by clicking anywhere in the row but you can't select the text in the row (because the link's pseudo-element is "covering" it). However, if you start a text selection outside the table, you can select the whole table (or the first however many rows you want).

This post includes some JavaScript as a progressive enhancement that tries to differentiate text selection from clicks.

https://css-tricks.com/block-links-the-search-for-a-perfect-...