I think I know the answer to this one, but just in case I've missed some new, ultra-clever CSS trickery of late...
Does anyone know of a non-JavaScript method (i.e. CSS) of changing the background colour of an entire row of table cells, and of making that entire row a clickable link?
No! Change the tr under
No!
Change the tr under what circumstance, have you got any conditions that change that can produce a new class somewhere or body tag?
Cant think of a means to make a tr clickable, a tr is just a holder for cells.
With the web apps that I
With the web apps that I develop, I often end up displaying complex tabulated data (not just simple lists) whereby each table row is logically linked to a database record that the user might want to see in more detail. Making one or more of the items of data into a clickable link is fine to a point, but the traditional effect of having the entire row a clickable link with a hover effect to aid usability is much more, well, 'usable'.
One solution is to make every item of data in the row into a link and then to set 'display' to 'block' and use :hover to change the background colour. But not only does that require a huge amount of extra mark-up, you also end up with just cell highlighting instead of row highlighting.
As much as I dislike using JavaScript for navigation, in this case it is not for a public website and the end (increased usability) justifies the means in my opinion:
1234
blar
blar
blar
As there are a few CSS experts out there frequently coming up with new solutions to old problems, I just wanted to check that this particular problem is still best solved with JavaScript.
IE aside. :hover will work
IE aside. :hover will work for a TR. IE will play ball with whatever:hover. Clicking to display something else is really only feasible with javascript. The :focus tricks could work, but that would mean you would need to attach the extra content to every item on the row, as I don't think TR can receive focus.
Clicking to load another page requires an anchor or javascript. Its not something CSS can ever do.
In Firefox, any element with
In Firefox, any element with a tab index ≥0 can have focus.
cheers,
gary