CSS a.selected font colour help

Soldato
Joined
5 Feb 2006
Posts
3,524
bit of help here please chaps.

i know .selected isn't a value in CSS. i have set up my links in my html with class="selected" to point to them. so that's all well and good.

now when it comes to changing it in css i can make it change the background with an image which is all good. how ever i can't change the font colour and its really really annoying me and i can't work out why it works with the background image but not the font colour

Code:
#header #links li.selected {
	color: #FFF ;
	background: url(../img/current-bg.gif) top left repeat-x;
	
	 }

so that makes the selected link as in the page you are currently on have the background as the image, all peachy.

Code:
#header #links li a.selected {
	color: #FFF;

}
but this doesn't work, why not o_0
 
You're probably not being specific enough with the CSS. Try:

#header #links li.selected a{
color: #FFF;
}

Btw, you should only need a class on the li and not the a tag
 
If your links all have a class of "selected" why are you being so specific with your css. Why not just do:

Code:
.selected a {
color: green;
}

And unless you want to specify css for each individual link, you should apply the class "selected" to the parent "ul" element.
 
Last edited:
If I am understanding correctly, you have only applied the class "selected" to the list element in which case you need to reference the link tag via:

#header #links li.selected a { color: #FFF; }
 
Back
Top Bottom