Re: Direct adjacent sibling selector (+)

Daniel Glazman wrote:
> 
> fantasai wrote:
> 
> > Does "immediately precedes" take text nodes into account?
> 
> No. 

Kinda undermines the selector's original purpose (as stated in CSS2):

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

  The next example reduces the vertical space separating an 
  H1 and an H2 that immediately follows it:

  H1 + H2 { margin-top: -5mm }   
</blockquote>

What if I did this?

  <H1>header 1</H1>
   Some anonymous text
   <H2>header 2</H2>

The result doesn't reflect the purpose of the style rule at all.

Now compare it to this:
  <H1>header 1</H2>
   Some <em>anonymous</em> text
   <H2>header 2</H2>

Creates a rather inconsistent layout, wouldn't you say?

Of course I realize this is sub-ideal coding of an HTML page,
but you can consider the same situation with some other elements.

> Section 6.6.5 says :
> 
> " Note that standalone PCDATA are not counted when calculating the
>   position of an element in the list of children of its parent. When
>   calculating the position of an element in the list of children of
>   its parent, the index numbering starts at 1."

That's a very awkward place to put a paragraph that affects the rest 
of the document. It looks like it only applies to structural pseudo-
-classes and nothing else.

Received on Saturday, 3 March 2001 22:39:10 UTC