I can’t seem to figure out how to make this css script only select the 4 links for the header. It makes all my links on my webpage green. How do I do this? I tried 1.ul{ css here} and 1.a:link,1.a:visited; etc. And then onI addedclass=’1’` but it still makes all links same as header links.
<style>
ul
{
list-style-type:none;
margin:0;
padding:0;
overflow:hidden;
}
li
{
float:left;
}
a.a:link,a.a:visited
{
display:block;
width:120px;
font-weight:bold;
color:#FFFFFF;
background-color:#98bf21;
text-align:center;
padding:4px;
text-decoration:none;
text-transform:uppercase;
}
a.a:hover,a:active
{
background-color:#7A991A;
}
</style>
</head>
<body>
<ul class"a">
<li><a class='a' href="#home">Home</a></li>
<li><a class='a' href="#news">News</a></li>
<li><a class='a' href="#contact">Contact</a></li>
<li><a class='a' href="#about">About</a></li>
</ul>
I’m not sure if its still the case but whenever I tried using numbers for classes it never worked unless there was a letter first. Either way numbers aren’t very semantic. You should try and describe what the element contains when creating id and class attributes.
I’d do this:
Then set CSS like this:
As Mattias pointed out will need to specify
#main-menueach time you target an anchor in the#main-menulist.Which is equivalent to: