...

View Full Version : a & a:hover but no a:visited = OK?



guermantes
12-18-2009, 02:49 PM
Hi,

Regarding the 'a:link :visited :hover :active' combo, is there any reason why I should include all four declarations in my style sheet even if I just want to make use of one? For instance as below:


a {
color:#405e95;
text-decoration:none;
}

a:hover {
text-decoration:underline;
}

Can such code malfunction in some browsers? Or be otherwise bad in some way...?

Thanks!

abduraooft
12-18-2009, 03:01 PM
is there any reason why I should include all four declarations in my style sheet even if I just want to make use of one?
I don't think so, but

Note: a:hover MUST come after a:link and a:visited in the CSS definition in order to be effective!!

Note: a:active MUST come after a:hover in the CSS definition in order to be effective!!

VIPStephan
12-18-2009, 03:02 PM
No, there is no reason. These pseudo classes are not required anyway. I, for example, am usually writing:


a {…}
a:hover {…}

which means that with the first rule all anchor elements are adressed (no matter whether they are a link, have been visited or are active or not) and with the second rule we’re overriding the styles of the first rule on mouseover.

The difference between a {…} and a:link {…} is that you can have anchors with href attribute (a link) or without (no link) and they are adressed accordingly (i. e. a:link wouldn’t adress anchors without href attribute).

Donkey
12-18-2009, 03:39 PM
I always include a:focus (for those navigating without a mouse) and a:active because IE6 seems to react to it in the same way that it should react to a:focus (but doesn't).

So I suggest that you should use:



a
{}

a:focus,
a:hover,
a:active
{}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum