Previous Message
Next Message

Re: [css-d] Adjacent selector madness

Sent by Eric A. Meyer on 25 September 2002 21:09


At 15:28 -0500 9/25/02, Austin Govella wrote:

>If I have a <div id="entry"> and then a <p>, then the folowing should work,
>  right?
>
>div#entry + p { text-indent: 0em; }

    Right, assuming that the element are in fact siblings.  In 
browsers that support adjacent-sibling selectors, at any rate.  So 
the above would match the 'p' element in:

    <div id="entry">...</div>
    <p>...</p>

It would NOT match the 'p' element in:

    <div id="entry">
    <p>...</p>
    </div>

You can test this out with IE5/Mac or any Gecko-based browser.  See, 
for example, 
<http://www.meyerweb.com/eric/css/tests/css2/sec05-07.htm>.

>Wouldn't div # p do the same thing, as well?

    Um, no.  'div # p' wouldn't do anything, as it's not a valid CSS2 
(or even CSS3) selector.

--
Eric A. Meyer (http://www.meyerweb.com/eric/), List Chaperone
"CSS is much too interesting and elegant to be not taken seriously."
   -- Martina Kosloff (http://www.mako4css.com/)
Previous Message
Next Message

Message thread: