Forum Moderators: not2easy
I am trying to have specific colours for my text links.
I amm using a css file and the styles are
a.link{
color:#F0AB00;
text-decoration:underline;
}
a.visited {
color:#0082D0;
text-decoration:underline;
}
a.active{
color:#0082D0;
text-decoration:underline;
}
a.hover{
color:#F0AB00;
text-decoration:underline;
}
this however does not seem to have any effect on the link colour at all (no matter how many refreshes i do)
The only way I can get it to change is by using
a {color:#0066CC; font-weight: bold}
however I also want a hover colour.
Any ideas what is blocking my styles from working?
.news a:link
{
color: #000099;
font-style: italic;
text-decoration: none;
}
.news a:visited
{
color: #D09962;
text-decoration: none;
}
.news a:hover, .news a:active
{
color: #A05000;
font-style: italic;
text-decoration: underline;
}
Thanks for any help.
Grump
@skizm: you were almost right, but the following code is better --
a:link {
text-decoration:underline;
color:#f0ab00;
}
a:visited,
a:active {
color:#0082d0;
}
Here's why:
It's been made shorter in several ways:
In addition, the pseudoclasses should always occur in the order
:link
:visited
:hover
:active
@Grump: your code can also benefit from some simplification --
.news a:link {
color:#009;
font-style:italic;
text-decoration:none;
}
.news a:visited {
color:#d09962;
}
.news a:hover,
.news a:active {
color:#a05000;
text-decoration:underline;
}
Again, the only things that change between your pseudoclasses are the color, and the text decoration on the :hover and :active states, so that's all you need to specify (you did get the order right though).
As for why your links won't turn blue, I guess one of three things (and we'll probably need a short, relevant html sample to decide for sure):
-b
All the links on your test page have been visited...Boy, do I feel dumb. I tested it with an address I haven't visited and the link renders just fine. Jeez.
But you also gave me hints for a cleaner CSS, thanks. I made some corrections (and added a focus attribute I just learned about). It's still not exactly like yours though:
.news a:link
{
color: #009;
font-style: italic;
text-decoration: none;
}
.news a:visited
{
color: #D09962;
}
.news a:hover, .news a:focus, .news a:active
{
color: #A05000;
text-decoration: underline;
}
My curly brackets are left aligned and it helps me read the CSS code better. Each attribute is actually tabbed once (5 spaces), but the message doesn't show that. Would I save much overhead by clustering the curly brackets as you did and eliminating the tabs?
Thanks again for your help.
Grump
good to see people helping people, but all I did was copy/paste his original. didn't have time to provide a detailed explanation or optimize so it's good to know theres folks out there whom have the time to provide further explanation. I'm sure many appreciate your help, keep up the good work amigo...
cheers!
-CW