0

Say for example I have the following styles:

#HorizNav ul li a.active:link { background-color: #FFF; }
#HorizNav ul li a.active:visited { background-color: #FFF; }
#HorizNav ul li a.active:active { background-color: #FFF; }
#HorizNav ul li a.active:hover { background-color: #FFF; }

If all the styles are the same, then how would I group these styles together?

Would it be like this?

#HorizNav ul li a.active:link, a.active:visited, a.active:active, a.active:hover { }
3
  • What if you ditched the pseudo-classes altogether? (:hover should come before :active by the way.) Commented Jun 24, 2012 at 23:35
  • thnx, but why does the order of pseudo-classes matter? Commented Jun 24, 2012 at 23:41
  • See this answer. Commented Jun 24, 2012 at 23:42

1 Answer 1

1

Simpler

#HorizNav ul li a.active { background-color: #FFF; }
Sign up to request clarification or add additional context in comments.

2 Comments

I'd guess that you really don't need that much specificity and #HorizNav a.active { background-color: #FFF; } would suffice and increase the speed of the selector.
@steveax: It also decreases the specificity, potentially making it unbalanced.

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.