On 8/15/05, BJ <[EMAIL PROTECTED]> wrote:
> "I've read there is a specific order which the anchors should be declared"
> <snippety>
> 
> Correct order:
> a
> a:link
> a:visited
> a:hover
> a:active

This isn't explicitly defined by the specifications, but comes from
thinking like a browser. :)

When an a tag is a link or it is visited, then a:link or a:visited
apply. When you hover over the link, it is still a link (visited or
otherwise) but now it's hovered as well. This means that both the
original a:link/a:visited _and_ a:hover are used to display the link.
When you click the link, then not only are you hovering over the link,
you are also making it active. And it's still a link.

According to the specs, if two rules have the same specificity and
define the same properties, the property value defined last wins.[1]
In this case, a:link, a:visited, a:hover and a:active all have the
same specificity. So if you're changing colors between states, then
the color defined by a:link or a:visited is defined first. If you
hover over the link, then as long as a:hover is defined after a:link
or a:visited, its color definition will override the link/visited
definition. If, however, you define the a:link/a:visited rules _after_
a:hover, then the color defined by a:hover will be overridden by the
color in a:link/a:visited. The same reasoning explains why a:active is
last.

HTH,

Michael

[1] http://www.w3.org/TR/CSS21/cascade.html#cascading-order (and
follow the "specificity" link for more about it)
______________________________________________________________________
css-discuss [EMAIL PROTECTED]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/

Reply via email to