New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Href for table rows #6223
Comments
You could use JavaScript. Is there a reason you need an entire row to be a link though? Why not have just one of the cells contain a link? Do you even need to be using a table for what you're doing? |
Using javascript is not the best idea, if one uses javascript for this purpose he should try to take care of all the different ways an anchor link is dealt in different operating systems/browsers/assistive tools, some of them being impossible to simulate. For example even if I take care of the behavior of different mouse buttons and keyboard modifier combinations (middle clicking, cmd + left click, ctrl + left click in another os, cmd + option + shift, etc) I still can't provide the "copy link", "open link in new tab" or "add link to bookmarks" items in the context menu of an anchor rendered by the browser, I'm sure there are many other details I cannot completely simulate with JS. |
An alternative just came to my mind is to partially ignore an anchor when used between a |
See https://github.com/whatwg/html/blob/master/FAQ.md#html-should-support-href-on-any-element. This indeed doesn't give you native UI for the entire row and it would be nice to offer that, but it's basically too much added complexity for a minor win. (We also cannot really change the HTML parser so that's not a viable route.) |
Thanks @annevk! Now I understand it better why this is not supported for any element and I wonder if it is also too complex to add I try hard to avoid hacks in the products I build and simulating anchors with javascript looks like a terrible hack. I think we all agree that it introduces inconvenience for the end user when she right clicks on a I'm not looking forward to see this implemented in major browsers in the next year, maybe it has lower priority than other concurrent issues, but I'm looking forward to see the community including people behind major browsers acknowledge this is an issue and needs to be resolved (maybe in 10 years or even unknown future.) |
The suggested solution is accessible as the actual link would be present in the first cell of the row. I'm personally happy to leave this open to see if such interest materializes, but I wouldn't bet on it. |
The suggestion in https://github.com/whatwg/html/blob/master/FAQ.md#html-should-support-href-on-any-element for Is adding It would:
I mean just check the number of likes here: https://stackoverflow.com/questions/17147821/how-to-make-a-whole-row-in-a-table-clickable-as-a-link |
@croraf please adhere to https://whatwg.org/code-of-conduct. Instead of silly, try inadequate (and as noted above, we know, but solving it is non-trivial). I wonder if an alternative solution here could be through CSS. Some kind of feature that allows elements to retarget user interaction. Might be too much of a boon for clickjackers though. |
I cannot find a way to render a table row that is actually a link too. This is possible to write something like this:
But as far as I understand it will make things hard for accessibility tools and may break some of them.
One solution that comes to my mind is to provide the ability to set an
href
property fortr
(and maybetd
) elements and converting them to anchor rows, but it may break many defaults or assumptions. So I would like to discuss it here.The text was updated successfully, but these errors were encountered: