a:link { color: #666;}a:visited { color: #030;}a:hover { color: #333;}a:active { color: #0C3;}
<html><head><title>Untitled Document</title><style type=\"text/css\">a { color: yellow; }a:link { color: red; }</style></head><body><p><a href=\"#\">Link Text</a></p><p><a>Anchor Text</a></p></body></html>
I've never really understood the magic of links and css, sometimes it just works using a:link instead of just a. How does it actually work?
Does the a element target both a:link, a:visited, a:active and a:hover? No..
When having to style nested menus it can get a bit messy with all the css selectors you need on a three-level-menu :)
When you use a: hover - you're being specific to the anchor hover state
like wise a:visited and a:active
I would guess the actual proper way to write it (if you try to think like the W3C) would be:
a:link {
color: red;
}
would affect:
<a href="#">something</a>
but not:
<a>something</a>
I could be wrong though? Someone should do a quick test =)
The outcome was:
Link Text
Anchor Text
I must have not saved on the refresh or something :?
Sorry about that.
Link Specificity, Ordering the Link States and Who Ordered the Link States?