I have the following:
<td>
some text
<div>a div</div>
</td>
I’d like to make the entire <td>...</td> a hyperlink. I’d prefer without the use of JavaScript. Is this possible?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, that’s possible, albeit not literally the
<td>, but what’s in it. The simple trick is, to make sure that the content extends to the borders of the cell (it won’t include the borders itself though).As already explained, this isn’t semantically correct. An
aelement is an inline element and should not be used as block-level element. However, here’s an example (but JavaScript plus a td:hover CSS style will be much neater) that works in most browsers:PS: it’s actually neater to change
ain a block-level element using CSS as explained in another solution in this thread. it won’t work well in IE6 though, but that’s no news 😉Alternative (non-advised) solution
If your world is only Internet Explorer (rare, nowadays), you can violate the HTML standard and write this, it will work as expected, but will be highly frowned upon and be considered ill-advised (you haven’t heard this from me). Any other browser than IE will not render the link, but will show the table correctly.