Reputation: 13
How to make individual cells in a table a hyperlink in html?
This is how I tried to make it and it did not work:
<table>
<tr>
<td id="Home">Home
<a href="Home.html"></a>
</td>
<td id="Locations">Locations
<a href="Locations.html"></a>
</td>
<td id="Accomodation">Accomodation
<a href="Accomodation.html"></a>
</td>
<td id="Transport">Transport
<a href="Transport.html"></a>
</td>
<td id="Contact">Contact Us
<a href="Contact Us.html"></a>
</td>
</tr>
</table>
Upvotes: 1
Views: 68
Reputation: 1
I think the problem here is that your tags actually does not show anything, so have 0px width tags. you can put test inside the tags, which will work. Example:
<a href="Home.html">Home</a>
Upvotes: 0
Reputation: 2103
The reason it didn't work because you didn't write home inside the tag. To make any text hyperlink, you have to put that text inside the tag.
In your case, you can make hyperlinks easily by putting Home, Location etc inside the the a tag like this:
<table>
<tr>
<td id="Home">
<a href="Home.html">Home</a>
</td>
<td id="Locations">
<a href="Locations.html">Locations</a>
</td>
<td id="Accomodation">
<a href="Accomodation.html">Accomodation</a>
</td>
<td id="Transport">
<a href="Transport.html">Transport</a>
</td>
<td id="Contact">
<a href="Contact Us.html">Contact Us</a>
</td>
</tr>
</table>
Upvotes: 0
Reputation: 6597
The problem is not the table, it's that there is no content in the <a>
tag, so, there's nowhere to click to trigger the link. Try this:
<table>
<tr>
<td id="Home">
<a href="Home.html">Home</a>
</td>
<td id="Locations">
<a href="Locations.html">Locations</a>
</td>
<td id="Accomodation">
<a href="Accomodation.html">Accomodation</a>
</td>
<td id="Transport">
<a href="Transport.html">Transport</a>
</td>
<td id="Contact">
<a href="Contact Us.html">Contact Us</a>
</td>
</tr>
</table>
Upvotes: 1