tags:

views:

108

answers:

5

Hi,

is there any way to make clickable <td> or <tr> tags?

Regards

Javi

+4  A: 
<td><a href="foo">bar</a></td>
Lie Ryan
Thanks, but imagine i give a padding to my <td> tag. If i move the mouse cursor into the cell you can see clearly that the <td> is not clickable, but just the word "bar"...
@user, `td { padding: someValue; } td a { display: block; margin: -someValue; padding: someValue; }` You may also want to add `text-decoration: none` to the `td a`.
eyelidlessness
Thanks! it works perfect!
+1  A: 
<td><a name="foo"/>bar</td>
Thilo
+3  A: 

To turn non-link tags into links, use @Lie Ryan's answer and put an a into the element.

To be able to link to an element:

Use an a

<a href="#idOfTheElement">Link to the element</a>

and a named point:

<td id="idOfTheElement">contents</td>
David Thomas
Cool. Is that a new feature? I thought you needed an anchor tag with a name (not just any tag with an id).
Thilo
@Thilo, it seems to work in all the newer browsers (including IE), but I'm not sure when it was introduced.
David Thomas
+1  A: 

<td>s can have a JavaScript onclick event.

Other than that, putting an <a> into the table cell, and giving it a fixed width to fill the table (you need to make it display: block for that) is the most reliable way.

Pekka
+1  A: 

If I understood correctly what you mean:

<td id="yourcell">Just a useless cell</td>

...
<a href="yourpage.html#yourcell">link</a>

Reference

Matteo Italia