HTML has two basic types of elements, inline elements and block elements.
If you want to know more about it, just read here.
Because them <a>
tag belongs to the class of the inline elements, it won't fill the whole table cell. The trick is to convert the anker tag with the link to a block element:
a {
display: block;
}
Now the anker will fill the complete cell.
Below you will find a code example on how this solution works.
I have two extra advices for you as beginner:
Use of Non-Standard Fonts
Please take care, if you are using unusual fonts like tradegothic
, which are not installed an all computers. If a visitor of a website does not have this font installed on his machine, he will see your website in the default font of his web browser.
If you want to use a custom font, please read here.
Do not use tables if not necessary
Using a table to display a navigation or other non-table data is mostly considered as a bad style of code.
Below you will find the exakt same looking navigation box without using an html table. This code could be considered to be more clean.
.nav {
width: 700px; /* Define the width of the navigation box */
padding: 0;
}
.nav li {
list-style-type: none;
margin: -1px 0 0 0;
}
/* Define the style of the ankers */
.nav a,
.nav a:visited {
display: block;
border: #315795 1px solid;
padding: 7px;
font-family: "tradegothic";
font-size: 14px;
font-weight: bold;
text-decoration: none;
color: #315795;
background: #bec7d6;
}
/* Define the hover style for the ankers */
.nav a:hover {
background-color: #315795;
color: #ffffff;
}
/* Define the Arrows */
.nav a::after {
content: "►►";
float: right;
}
<ul class="nav">
<li><a href="http://stackoverflow.com">CENTER FOR MATHEMATICAL & COMPUTATIONAL MODELING IN BIOLOGY & MEDICINE</a></li>
<li><a href="http://stackoverflow.com">OUR PEOPLE - COMMITTEES</a></li>
<li><a href="http://stackoverflow.com">SEMINARS, COLLOQUIUM, CONFERENCES & RESEARCH</a></li>
</ul>
Original Solution with Table
If you, for whatever reasons, prefer the table solution, here you will find the fixed code.
.hoverTable {
width: 700px;
border-collapse: collapse;
}
.hoverTable td {
padding: 0;
border: #315795 1px solid;
}
/* Define the style for normal and visited links */
.hoverTable a,
.hoverTable a:visited {
display: block;
padding: 7px;
text-decoration: none;
font-weight: bold;
font-family: "tradegothic";
font-size: 14px;
color: #315795;
background: #bec7d6;
}
/* Define the hover style for the links */
.hoverTable a:hover {
color: #ffffff;
background: #315795;
}
<table class="hoverTable">
<tbody>
<tr class="clickable-row" data-href="mathdept.ucr.edu">
<td colspan="3"><a href="http://stackoverflow.com">CENTER FOR MATHEMATICAL & COMPUTATIONAL MODELING IN BIOLOGY & MEDICINE<span style="float: right;">►►</span></a></td>
</tr>
<tr>
<td colspan="3"><a href="http://stackoverflow.com">OUR PEOPLE - COMMITTEES <span style="float: right;">►►</span></a></td>
</tr>
<tr>
<td colspan="3"><a href="http://stackoverflow.com">SEMINARS, COLLOQUIUM, CONFERENCES & RESEARCH <span style="float: right;">►►</span></a></td>
</tr>
</tbody>
</table>