Your Search Results

    General sibling selectors

    Summary

    The ~ combinator separates two selectors and matches the second element only if it is preceded by the first, and both share a common parent.

    Syntax

    element ~ element { style properties }
    

    Example

    p ~ span {
      color: red;
    }
    <span>This is not red.</span>
    <p>Here is a paragraph.</p>
    <code>Here is some code.</code>
    <span>And here is a span.</span>

    Specifications

    Specification Status Comment
    CSS Selectors Level 3 Recommendation  

    Browser compatibility

    Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
    Basic support Any 1.0 (1.7 or earlier) 7 9 3
    Feature Firefox Mobile (Gecko) Android IE Phone Opera Mobile Safari Mobile
    Basic support ? Any ? ? Any

    See also

    Document Tags and Contributors

    Contributors to this page: Sheppy, SphinxKnight, tiffon, Miken32, FredB, ethertank, DanSorahan, teoli, dhar
    Last updated by: DanSorahan,
    Hide Sidebar