ARTICLE AD BOX
I need to make table cells (or rows) link to other pages. Currently they're using onClick to change url, but it's missing the UX of actual anchor elements, such as opening in new tab etc.
I tried replacing the entire row with an <a> and display: table-row style, and it works perfectly... except React insists that a is not a valid child of tbody and td is not a valid child of a.
Am I supposed to remake the entire table using styled divs, or what's the solution here?
Edit:
I have tried to make <a> cover every cell, but it's very hard to make that happen reliably since height: 100% does not work. Absolutely positioned links work only if the cell does not have any interactive contents. Using both at the same time (with absolutely positioned link behind the normal one) probably works but that's a lot of extra elements.
7,5154 gold badges42 silver badges75 bronze badges
3
No, you can not. because <tr> can only contain <td> tags. what you can do is putting <a> tags inside <td> and use CSS to fill the td. your CSS style would be something like this:
.cell-link { display : block; width : 100%; height : 100%; text-decoration : none; color : inherit; }Also i strongly suggest not using onclick on cells if SEO matters and you are not planning to implement any back-rendering. this can cause problems with crawler bots (you're page indexing process on search engines).
23k6 gold badges28 silver badges46 bronze badges
2 Comments
height: 100% does not work unless parent element has a fixed height, and I can't predict the height of my rows. That's basically the main reason why I'm looking for a workaround. I tried absolutely positioned links too, but then they either cover the cell contents or are covered by it.
2026-02-14T19:57:08.203Z+00:00
From what I understand of your question,
Are you looking for something like that ?
23k6 gold badges28 silver badges46 bronze badges
"I have tried to make <a> cover every cell". Something like this?
19k2 gold badges15 silver badges33 bronze badges
Explore related questions
See similar questions with these tags.
