I have a table of data and each cell is a link. I want to allow the user to click anywhere in the table cell and have them follow the link. Sometimes the table cells are more than one line but not always. I use td a {display: block} to get the link to cover most of the cell. When there is one cell in a row that is two lines and the others are only one line the one liners don’t fill the entire vertical space of the table row. Here is the sample HTML and you can see it in action here http://www.jsfiddle.net/RXHuE/:
<head>
<style type="text/css">
td {width: 200px}
td a {display: block; height:100%; width:100%;}
td a:hover {background-color: yellow;}
</style>
<title></title>
</head>
<body>
<table>
<tbody>
<tr>
<td>
<a href="http://www.google.com/">Cell 1<br>
second line</a>
</td>
<td>
<a href="http://www.google.com/">Cell 2</a>
</td>
<td>
<a href="http://www.google.com/">Cell 3</a>
</td>
<td>
<a href="http://www.google.com/">Cell 4</a>
</td>
</tr>
</tbody>
</table>
</body>
You need a small change in your CSS. Making
tdheight:100%;works for IE 8 and FF 3.6, but it doesn’t work for Chrome.But making
heightto50pxworks for Chrome in addition to IE and FFEdit:
You have given the solution yourself in another post here; which is to use
display: inline-block;.This works when combined with my solution for Chrome, FF3.6, IE8
Update
The following code is working for me in IE8, FF3.6 and chrome.
CSS
HTML
The example lays here