General sibling
Specifies a general sibling relationship between selector elements.
Syntax
E~
F {
sRules }
Possible values
E |
String that specifies the name of a document language element type or simple selector. |
F |
String that specifies the name of a document language element type or simple selector. |
sRules |
String that specifies one or more cascading style sheet property/value pairs. |
Remarks
The general sibling combinator is a "tilde" character (~) that separates two simple selectors. White space is not significant.
A selector of the form "E~
F" matches element F when it follows sibling element E in the document tree, ignoring non-element nodes (such as text nodes and comments). Elements E and F must share the same parent but E need not directly precede F. To match the first child of the parent, use the :first-child pseudo-class.
Example
The following example reduces the vertical space that separates an H1 element and the H2 element that immediately follows it:
<style>
h1~h2 {margin-top: -5mm;}
</style>
Standards information
This selector is defined in Cascading Style Sheets (CSS), Level 3 (CSS3) .
See also
Concepts
Understanding selectors
Adjacent sibling
Child
Descendant
Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.