Re: a:hover and a:active and named anchors

L. David Baron wrote:
> On Friday 2002-07-26 11:27 -0400, Stuart Ballard wrote:
> 
>>What *did* occur to me though is that it would be possible for the 
>>default user-agent stylesheet to workaround these issues. For example:
>>
>>a:not(:link):hover, a:not(:link):active {
>>   font: initial;
>>   background-color: initial;
>>   color: initial;
>>   list-style-item: initial;
>>}
> 
> 
> This wouldn't work, for two reasons:
> 
> First, these styles would not override any styles in an author
> stylesheet, unless they were !important (in a way that override author
> stylesheets -- !important in UA stylesheets isn't technically defined).
> This is because the weight & origin sort in the cascading order is a
> higher priority sort than any other.

I must be confused. Doesn't specificity come into play at that level? If 
it does, the specificity of a:not(:link):hover is clearly higher than 
a:hover and so it would override. If it doesn't, does that really imply that

* {display: inline}

in an author stylesheet would override all the specific

p, div, ... {display: block}

in the UA stylesheet?

> Second, if they did override author stylesheets (due to !important or
> something like it), they would also override the non-:hover/:active
> styles in the user stylesheets, and the author's link styles that didn't
> have event state selectors would be overridden with the default when the
> element was in the :hover or :active state.

That's only a problem if the author really intended to style <a name>, 
which is extremely unlikely - far more common will be that the author 
styled "a" when they actually meant to style "a:link". If there were 
situations in their document where this made a difference, presumably 
they'd have corrected their code to ensure that the wrong "a"s didn't 
get styled in the first place. It seems to me that it would be very rare 
for <a name> to get *any* specific style, let alone the *same* style as 
<a href> - which would have to be what happened in order to get a 
selector with a specificity that would be overridden by my proposed UA 
sheet, if I understand specificity correctly (which I might not, I guess).

If the <a name> wasn't styled specifically, you'd get "initial" which 
would map to "inherit" for most of those properties, and so if something 
*containing* the <a name> was styled, everything would still work just fine.

Stuart.

-- 
Stuart Ballard, Programmer
NetReach - Internet Solutions
(215) 283-2300, ext. 126
http://www.netreach.com/

Received on Friday, 26 July 2002 12:02:29 UTC