

Re: Selecting selectors

From: Ian Hickson <py8ieh@bath.ac.uk>
Date: Sun, 14 Mar 1999 21:12:11 +0000 (BST)
To: Ignacio Javier <ignacio.gomez@dicoruna.es>
Message-ID: <Pine.GSO.4.04.9903142040480.21791-100000@midge.bath.ac.uk>
On Sun, 14 Mar 1999, Ignacio Javier wrote (in a rather surreal moment):

>  <h1>
>      <p>
>     I'm not a paragraph that involves easily with bad guys. In fact I
> love one paragraph ...his name is .... is..I love a not selectable
> paragraph?
>     </p>
>  </h1>

(I assume this is not HTML.  If this is HTML, then the above is invalid.)

That paragraph can be selected with the following selector:

   h1 p 


   h1 > p



> <p>
>  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.

> <h1>
> </h1>
> <p>
> 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

...or, if we use my suggestion from a few months back of a pseudo-class
selector :contains,

   h1:contains(P) + P

The paragraph after the second h1 can be selected by

   h1 + p + h1 + p

or just

   * + h1 + p

> Will the president of CSS country have to give an identifier to
> citizen Cool?

Depending on the situation, that may actually be the better solution.
After all, why do you want to select the _second_ p-after-h1? Is it
actually the first-p-after-an-h1-following-any-number-of-ps-following-an-
h1? Or is it a paragraph containing a particular piece of data?

Ian Hickson 
U+2642 U+2651
U+262E U+2603 U+263A
Received on Sunday, 14 March 1999 16:12:20 GMT
