- From: Bert Bos <bert@w3.org>
- Date: Mon, 9 Oct 2000 15:27:39 +0200 (MEST)
- To: www-style@w3.org
Ian Hickson writes:
> How would you style target anchors? (In HTML, the <a> element that does
> not have an href attribute.)
>
> Currently, you can only do so if you style the links as well:
>
> a:link, a:visited { color: blue; }
> :root a { color: green; } /* root is needed to get the specificity high enough! */
>
> This proposal adds an equivalent negative pseudo-class for every
> pseudo-class, so instead you could just do:
>
> a:not-link, a:not-visited { color: green; }
Hmm, there are at least two logical errors here: (1) *every* A's is
either not-link or not-visited, so this makes all A's green. Maybe you
meant a:not-visited:not-link? (2) However, that still doesn't style
target anchors, just A elements without an HREF or whose HREF doesn't
contain a URL. To make target anchors green, you probably want this
rule:
a[name] { color: green }
Actually, for newer versions of HTML you need this instead:
*[id] { color: green }
Reasoning with negatives is rather hard; let's try to avoid it.
Bert
--
Bert Bos ( W 3 C ) http://www.w3.org/
http://www.w3.org/people/bos/ W3C/INRIA
bert@w3.org 2004 Rt des Lucioles / BP 93
+33 (0)4 92 38 76 92 06902 Sophia Antipolis Cedex, France
Received on Monday, 9 October 2000 09:27:45 UTC