Hi,
You are dealing with separate elements here.
The anchor in one cell has no relationship with the anchor in another cell. The anchors will only be as tall as the content they hold. An anchor can't be made to fill a whole table cell because things just don't work like that.
You could make the whole cell change colour but not make the whole cell a link.
You can actually do it with the CSS display:table property and make the anchor itself a table-cell but this only works in ie8 and upwards and isn't very semantic.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
.test {
margin:0;
padding:0;
display:table;
}
.test a {
background:red;
vertical-align:middle;
border-right:10px solid #fff;
padding:10px;
display:table-cell;
text-decoration:none;
}
.test a:hover {background:blue}
.test span{
position:absolute;
top:-999em;
left:-999em;
}
</style>
</head>
<body>
<div class="test">
<a href="#">test<br />
test</a><span>|</span>
<a href="#">test</a><span>|</span>
<a href="#">test</a><span>|</span>
<a href="#">test</a><span>|</span>
<a href="#">test</a><span>|</span>
<a href="#">test</a><span>|</span>
<a href="#">test</a><span>|</span>
</div>
</body>
</html>
To cater for other browsers you will probably have to set a specific height if you want them to all be equal height.
Bookmarks