views:

46

answers:

2

Should we always use all these pseudo selectors with different colors?

a:link { color: blue }
a:active { color: white;}
a:hover { color: white;}
a:visited {color:green;}

Basically we define these for links in the main content area, but then the problem is that it overrides all side bar links, navigation links, etc also, then we need to create define all again for navigation links if navigation has different color scheme?

Update: And another problem is if we decide to use all then how to decide color for active, hover and visited because client and designer never provide color for all. they only provide color of link

+2  A: 

There is no need. Define the ones you want to define. Allow the cascade to work as normal for the ones where you are happy for that to happen.

In the case you describe, it sounds like you are not happy for that to happen. So you should define styles for the states in each case.

As a few asides…

  • It is usually a good idea to define :focus too.
  • Most people want :hover effects to apply to visited and unvisited links, so :hover should appear after :link and :visited in the source (you might not want this, but most people do)
  • Links are usually activated by being clicked on. You can't click on a link without hovering it. You should almost certainly define :active after :hover and :focus.
David Dorward
i think it's better to define for #main-content {....} only. and :focus does not work in IE so IE user will not get focus style
metal-gear-solid
I don't have it handy to test, but I'd be very surprised if IE8 lacked support for `:focus`. There is no reason not to invest a tiny bit of time adding support for something supported by most major browsers though (even if that doesn't include IE) — if it isn't supported, users are no worse off.
David Dorward
yes you are right i was just saying about IE. is it not mean, i will not add :focus
metal-gear-solid
A: 

In regards to your nav question, I would, in most cases, try to avoid defining different color scheme's/behaviors for identical elements (in this case a) across your site.

Bobby