[CSS Selector] E ~ F
Using '~' (tilde) applies styles to all subsequent sibling elements. This is generally called the 'general sibling combinator'. The condition is that the elements share the same parent element and appear after the specified element. Note that it does not work in IE6 and below.
Sample Code
h2 ~ p { color: red;} /* Applies to all p elements that are subsequent siblings of an h2 element. */
Browser Display Result
h2 ~ p { color: red;} /* Applies to all p elements that are subsequent siblings of an h2 element. */
<p>This is a p element.</p> <h2>This is an h2 element.</h2> <p>This is a p element.</p> <p>This is a p element.</p>
Browser Compatibility
Desktop
2 and earlier ×Supported in all versions
8 ○
7 ○
6 ×
8 and earlier ×Mobile
Android Browser
4.4+ ○
3 and earlier ×Same support as desktop
Same support as desktop
※ Version data is based on MDN.
If you find any errors or copyright issues, please contact us.