FW: a:hover and a:active and named anchors

Are there any plans for CSS to be able to select an element that has a
particular attribute?  For example, suppose I want to style only the <a>
elements that have an href attribute.  Perhaps something like this:

a[href] { background-color: #f00 }

Or perhaps:

a[href]:hover { background-color: #f00 }

This would only apply the style to <a> elements containing an href
attribute, so <a name="foo"> would not be affected by this style.

Then to expand this even further, perhaps you could also select an element
that has a particular attribute that has a particular value.  For example:

a[href="http://www.w3c.org"]:hover {background-color: #f00 }
a[target="_blank"]:hover { background-color: #0f0 }

Of course, you could get around all of this by using classes.  For example:

<a href="xxx" class="ahref">xxx</a>
<a name="yyy" class="aname">yyy</a>
<a href="zzz" class="ahref">zzz</a>

Then you only apply the :hover rule to links of class "ahref".
Just thinking out loud.  :)

-Pete


> -----Original Message-----
> From: www-style-request@w3.org [mailto:www-style-request@w3.org]On
> Behalf Of Lachlan Cannon
> Sent: Friday, July 26, 2002 4:15 AM
> To: Jerry Baker
> Cc: www-style
> Subject: Re: a:hover and a:active and named anchors
> 
> 
> 
> 
> 
> Jerry Baker wrote:
> > 
> > So instead of saying something like named anchors can't 
> have :hover and 
> > :active states, why not something like invisible and non-structural 
> > elements cannot have :hover and :active states?
> > 
> > 
> 
> What's wrong with using the link pseudo-class when you have 
> to use a's 
> as names as well? a:link a:link:hover ... I also don't see 
> the point of 
> changing this for css3 when css2 hasn't properly been implemented yet 
> and yet the vast majority of people have already moved to 
> html 4 / xhtml 
> 1. By the time this was implemented there'd likely be even 
> less reason 
> for it.
> 
> Besides, invisibles couldn't have these states (how can something be 
> hovered when it's not even displayed?) and how is the browser 
> meant to 
> know whether an arbitrary xml tag is structural or non-structural?
> 
> -- 
> Lach
> __________________________________________
> http://members.evolt.org/luminosity/
> MSN: luminosity @ members.evolt.org
> __________________________________________
> 
> 

Received on Friday, 26 July 2002 10:46:45 UTC