I would like a table cell to act as my hyperlink. What I have currently is a hyperlink embedded in a table cell, hence it is only when the exact underlined hyperlink text is clicked that the url is obeyed. But not when you click anywhere else. [e.g <tr><td><a href=www.meme.com>clickMe </a></td></tr>]
In the example, the url only works where I click on "Click Me" and not anywhere on the table cell. Please, a helping hand is needed.

Recommended Answers

All 2 Replies

Member Avatar for Rhyan

I would like a table cell to act as my hyperlink. What I have currently is a hyperlink embedded in a table cell, hence it is only when the exact underlined hyperlink text is clicked that the url is obeyed. But not when you click anywhere else. [e.g <tr><td><a href=www.meme.com>clickMe </a></td></tr>]
In the example, the url only works where I click on "Click Me" and not anywhere on the table cell. Please, a helping hand is needed.

Hi there.

If you try to code it like this :
<table><tr><a><td>My link here</td></a></tr></table>

your code may not validate, or result in another error.

Do you have something else apart from text link inside your cell?

In case you have some short text, e.g. "Click here" and your cell is wither or higher than this text, you can make one of the following:

Case 1 - your text is wide as wide as the cell is, however it is not that high - you can set it like this with css:

...<td style="line-height: 50px; font-size: 12px;"><a href="#"> Click me! </a></td>...

In this way, if your cell is 50px high, and your text size is 12px, wherever you point your cursor - it will change as a link pointer.

Case 2
Well - it si more complex, and if you have any other elements in this cell, like images, additional text, etc. it may turn to be a problem, still you can try it. You can set the following css to your link:

...<a href="#" style="display: block; width: 100px; height: 50px;">Click me!</a>....

Try it and advise...

Thanks so much for Case 2! I just tried it and it works fine with Firefox, IE, Safari and Google Chrome. I intend to use a jpg with fancy script as the background image for the entire table. Then I will adjust the cell and row dimensions to create my one-cell hot link zones. Finally, I will have a single period as the linked text. I can change the color of the one character to become invisible by blending in with the background. Thanks again.

commented: start your own thread, do not try to attach to one three years old, in the proper language, "cgi" is the perl language, just as it states in the first line of the code submitted. Read the F instructions -1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.