开发者

Is it good to define every link state pseudo-class with different colors?

开发者 https://www.devze.com 2022-12-20 04:17 出处:网络
Should we always use all these pseudo selectors with different colors? a:link { color: blue } a:active { color: white;}

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


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号