tags:

views:

25

answers:

4

I'm having a bit of difficulty adding some CSS to a link. I'm using a CMS that automatically generates menus in an unordered list. However, where you're on a given page, it applies class="active" the the li and not to the link itself. This works fine for adding a background to the link, but I'm trying to change the link color.

<li class="active">
<a href="#">Link</a>
</li>

I'm having difficulty coming up with the CSS to say "If a link is in an li with class="active" then make the link text color x."

How might I accomplish this?

Thanks!

A: 

.active a {color: red;}

Badr Hari
This is incorrect - the full stop should move before the class name
John Catterfeld
you have the '.' in the wrong place. .active a { }
Cfreak
I made a mistake, corrected it in 5 sec and with that time I have 2 people correcting me already =)
Badr Hari
@Badr that's Stack Overflow for ya :) I would upvote to even out the unfair -2 but I'm out of votes for today.
Pekka
A: 
a
{
    color: black;
}
a.active
{
    color: green;
}
Dustin Laine
won't work either. He want's only the link within the li that has a class as 'active'. Your first would change all a tags. The second would look for a tags that have class="active" on them.
Cfreak
+3  A: 

the path is

li.active a { color: .... }

The MDC CSS Reference has good examples for the various types of selectors.

Pekka
+1  A: 
li.active a {color:whatever}
joni