Export (0) Print
Expand All

General sibling

Specifies a general sibling relationship between selector elements.

E~F { sRules }

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.

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.

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>

Community Additions

ADD
Show:
© 2014 Microsoft