...

View Full Version : Can you hyperlink a td.......



m_baggley
08-17-2005, 05:02 PM
....rather than text or an image?

Anyone know if this is even possible? Please let me know if so

Cheers

Matt

Pennimus
08-17-2005, 05:07 PM
Not technically.

But you can hyperlink text or an image (perhaps invisible?) inside a td and use CSS to count the entire cell as a link.

m_baggley
08-17-2005, 05:20 PM
there is text in the Td, but I didn't want to hyperlink the text, but the whole td. Hmm not sure what to do.........

mrruben5
08-17-2005, 06:01 PM
<td onclick="window.location='http://www.google.com'">Google</td>I must stress though this is not search engine friendly. You could style the link as a "block" with "display:block;"

m_baggley
08-17-2005, 06:07 PM
...thank you very much. Theres no issue with search engines as it is an internal website only. What do you mean by block?

Pennimus
08-17-2005, 06:32 PM
Thats what I meant about using CSS. It effectively turns the whole cell into a link.

HTML -



<td class="nav">
<a href="whatever.php">Clean Rooms</a>
</td>



Stylesheet -



.nav a {
display: block;
}


... and whatever other styles you want.

I use this a lot to have the whole cell background colour change when the cell is mouseovered.

Ultragames
08-18-2005, 10:38 AM
If you style the text with no decoration, and standard coloring, and block the link, the text will look the same, yet the whole <td> will be the link.

m_baggley
08-18-2005, 05:05 PM
thank you all for your assistance.

Matt

Bill Posters
08-18-2005, 05:22 PM
.nav a {
display: block;
}

If the table cell is taller than the text you'll need to specifically set the height (or top/bottom padding) to make sure that the anchor area expands to fill the cell vertically too.

e.g.

.nav a {
display: block;
height: 100%;
}

Just a heads up. :)

Pennimus
08-19-2005, 11:06 AM
And the width, presumably...

mrruben5
08-19-2005, 11:13 AM
No you don't have to do that. Elements with display:block as style automaticly fill the entire width, such as a div.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum