5

I have a html menu:

<ul>
<li><a href="#" class="active">Item one</a></li>
<li><a href="#">Item two</a></li>
<li><a href="#">Item three</a></li>
</ul>

and css:

ul li a{
     color: black;
}
ul li a:hover, ul li a.active{ /* it was ul li a:hover for two times */
     color: red;
}

When I'm hovering on a non-active element, there is two red elements and it is normal. The problem is changing color for hover-element only and removing it on active (turn to black). Is there any trick to do this without JS?

edited: there was an error. ctrl-c -> ctrl-v is evil

2
  • Your CSS looks wrong. Is that supposed to be ul li a.active, ul li a:hover rather than ul li a:hover, ul li a:hover? Commented Nov 22, 2011 at 15:02
  • ul li a:active {color: black; } Commented Nov 22, 2011 at 15:04

2 Answers 2

3

Assuming your ul element isn't bigger than the space your li s take up:

ul:hover a.active
{
    color: black;
}

Or possibly Shawn's answer, depending on if you're talking about the class active or the link status.

Sign up to request clarification or add additional context in comments.

1 Comment

you are welcome Alexander, but you might want to check this answer as accepted one, just so that other members could know that this issue is solved.
0
ul li a:active {
     color: black;
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.