Have a quick gander at the CSS level 2 spec below:
The upshot is that you cant do what you want. HR + P {...css stuff...}
selects the <P> shown below, but you can only select a tag that is preceded
another tag, not a tag that preceds another tag. I don't know which browsers
support this though.
<hr>
<p>style this</p>
<p>don't style this</p>
<ul>
<li>one</li>
<li>two</li>
</ul>
<p>don't style this</p>
HTH, Adam
Cascading Style Sheets, level 2 CSS2 Specification
(http://www.w3.org/TR/REC-CSS2)
5.7 Adjacent sibling selectors
Adjacent sibling selectors have the following syntax: E1 + E2, where E2 is
the subject of the selector. The selector matches if E1 and E2 share the
same parent in the document tree and E1 immediately precedes E2. In some
contexts, adjacent elements generate formatting objects whose presentation
is handled automatically (e.g., collapsing vertical margins between adjacent
boxes). The "+" selector allows authors to specify additional style to
adjacent elements.
Example(s):
Thus, the following rule states that when a P element immediately follows a
MATH element, it should not be indented:
MATH + P { text-indent: 0 }
The next example reduces the vertical space separating an H1 and an H2 that
immediately follows it:
H1 + H2 { margin-top: -5mm }
Example(s):
The following rule is similar to the one in the previous example, except
that it adds an attribute selector. Thus, special formatting only occurs
when H1 has class="opener":
H1.opener + H2 { margin-top: -5mm }
-----Original Message-----
From: Jon Haworth [mailto:[EMAIL PROTECTED]]
Sent: 15 October 2002 20:58
To: [EMAIL PROTECTED]
Subject: [wdvltalk] Re: CSS selector help - aargh
Oh, this is getting silly. I'm sorry.
> > I need a rule that affects any <foo> that is
> > followed immediately by a <bar>.
>
> Make the first <li> of any <ul> red:
Alert readers will notice that's wrong at least twice. Obviously, I'm not
feeling too alert right now ;-)
Let me try again.
I need to style any <p> that is followed by a <ul>:
<p>don't style this</p>
<p>style this</p>
<ul>
<li>one</li>
<li>two</li>
</ul>
<p>don't style this</p>
If anyone can post a selector for this I will be very grateful. I look
forward to reading it when I get out of bed tomorrow morning :-)
Cheers
Jon
____ * The WDVL Discussion List from WDVL.COM * ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED]
Send Your Posts To: [EMAIL PROTECTED]
To change subscription settings to the wdvltalk digest version:
http://wdvl.internet.com/WDVL/Forum/#sub
________________ http://www.wdvl.com _______________________
You are currently subscribed to wdvltalk as: [EMAIL PROTECTED] To
unsubscribe send a blank email to %%email.unsub%%
____ � The WDVL Discussion List from WDVL.COM � ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED]
Send Your Posts To: [EMAIL PROTECTED]
To change subscription settings to the wdvltalk digest version:
http://wdvl.internet.com/WDVL/Forum/#sub
________________ http://www.wdvl.com _______________________
You are currently subscribed to wdvltalk as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]