W3C home > Mailing lists > Public > www-style@w3.org > March 1999

Re: Selecting selectors

From: Ian Hickson <py8ieh@bath.ac.uk>
Date: Wed, 17 Mar 1999 02:15:47 +0000 (BST)
To: Ignacio Javier <ignacio.gomez@dicoruna.es>
cc: www-style@w3.org
Message-ID: <Pine.GSO.4.04.9903170135090.16393-100000@amos.bath.ac.uk>
On Wed, 17 Mar 1999, Ignacio Javier wrote:
>>>  <h1>
>>>      <p> [first] </p>
>>>  </h1>
>>>  <p>
>>>     [second]
>>>     I'm cool, I'm a good guy, but someone is using my
>>>     personality!??? I fact I'm the paragraph loved by the one
>>>     above, his name is h1 > p ....
>>>  </p>
>> That would be h1 + p, I think.
> I would get the last Bad P too

Yes. I was just correcting your comment saying it was "h1 > p" (which
would match the first <p> in this document (at the top), not this
one, the second).


>>>  <h1> </h1>
>>>  <p>
>>>   [third]
>>>   I'm a very bad guy, but fortunatelly people confuses me with the
>>>   paragraph above, ha ha!!!
>>>  </p>
>> The first one can be selected by
>>    h1:first-child + p
> suppose you mean p:first-child + p

No. The first p of the standalone ps, labelled "[second]" above, is
definitely selected by the

   h1:first-child + p

...selector.

Your

   p:first-child + p

...selector matches nothing in this tree (it would match a P that came
directly after another P, but only if that P was the first element in
its parent).


> I need to clarify the following: (excuses if I use bad terminology):
> If you want a selector syntax to be capable of complex selections it
> might be able to select in base to structures. I mean, if you have a
> document in a stable way (loaded) then you can have all info about
> structure on it, and why not refer to selectors by tree?
> Example:
>   (h1 > p) + p
>   h1>p will refer to p that.....
>   h1:contains(p) will refer to h1 that....
> but more generic (...) denote tree structure and so:
>   (h1 > p) + p 
> denotes a p that has sibling relation with an h1 that has a p child
> in structure
>   p < h1
> will denote as selected an h1 that has a p as child, but:
>   (p < h1) would be equal to (h1 > p)

The above can mostly be done by using :contains() (although in its
current incarnation I would have trouble emulating "(h1 > p) + p"
accurately -- the closest you can get is "(h1 p) + p" -- see below).

Your suggestion has one major problem, which is that it introduces
nesting at the selector level. The CSS grammar currently has no
mechanism for explaining how this works, other than functions, which
is what the :contains() idea uses. I would be wary of playing fast and
loose with the core grammar of CSS, as doing so implies having to
rewrite parts of CSS implementations' parsers.


> h1 > ( p + p em )

h1:contains( p + p em )

Although again, there is no way to specify that the contents must be
immediate children.

Hmm. This is something that should be fixed. 

The only way I can see of doing it would be to have two pseudo-
selectors. I don't like that idea though.

As in:
 
   h1:ancestor-of( p + p em )
   h1:parent-of(p + p em)

There must be a better way, though.

-- 
Ian Hickson 
U+2642 U+2651
U+262E U+2603 U+263A
Received on Tuesday, 16 March 1999 21:15:51 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:53:58 GMT