0

I have a site made of table for its layout but the links can't be styled correctly

My table code for the navbar

<table id="table">
<tr class="navbar">
<td><a href="#">HOME</a></td>
<td><a href="#">MY PROFILE</a></td>
<td><a href="#">MY WORKS</a></td>
<td><a href="#">ABOUT SITE</a></td>
</tr>
</table>

My CSS code

a.navbar:link {
    color:whitesmoke;

}

a.navbar:visited {
    color:red;

}

a.navbar:hover {
    color:red;
    background-color: yellow;

}

a.navbar:active {
    color:red;

}
jerome_mjt
  • 280
  • 3
  • 12

4 Answers4

1

Your CSS selectors are not correct as the links do not have the class navbar.

A correct solution would be to select an element of type a within an element of class navbar like this:

.navbar a:link {
    color:whitesmoke;
}

.navbar a:visited {
    color:red;
}

.navbar a:hover {
    color:red;
    background-color: yellow;
}

.navbar a:active {
    color:red;
}

Why this use of html tables in general might not be the best option possible is extensively discussed on SO.

Community
  • 1
  • 1
Daniel
  • 3,541
  • 3
  • 33
  • 46
1

Switch it around:

.navbar a { *styles* }
SigmaSteve
  • 664
  • 6
  • 25
1

a.navbar selects a elements that have the class navbar. You have to use .navbar a {} in this case.

I would not use tables as menus by the way. I recommend using uls instead since they can be styled more sophisticatedly.

Niklas Vest
  • 872
  • 6
  • 20
1

try

.navbar > td > a:link {...}

etc.

Johannes
  • 64,305
  • 18
  • 73
  • 130