Dummy annotation to show color coding levels:
Pass Almost pass Slightly buggy Buggy Very buggy Fail Epic Fail Untested
Test information available from the nightly build of the CSS 2.1 Test Suite.
9506 Tests
Gecko Presto Trident Webkit AHFormatter Prince WebToPDF
9251 pass, 249 fail, 6 untested

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, ignoring non-element nodes (such as text nodes and comments).

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 a class selector. Thus, special formatting only occurs when H1 has class="opener":

 
h1.opener + h2 { margin-top: -5mm }   
Test information available from the nightly build of the CSS 2.1 Test Suite.
9506 Tests 6 untested, please test
Gecko Presto Trident Webkit AHFormatter Prince WebToPDF

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, ignoring non-element nodes (such as text nodes and comments).

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 a class selector. Thus, special formatting only occurs when H1 has class="opener":

 
h1.opener + h2 { margin-top: -5mm }