mozilla
Your Search Results

    Child selectors Redirect 1

    Summary

    The > combinator separates two selectors and matches only those elements matched by the second selector that are direct children of elements matched by the first. By contrast, when two selectors are combined with the descendant selector, the combined selector expression matches those elements matched by the second selector for which there exists an ancestor element matched by the first selector, regardless of the number of "hops" up the DOM.

    Syntax

    selector1 > selector2 { style properties }
    

    Example

    span { background-color: white; }
    div > span {
      background-color: DodgerBlue;
    }
    
    <div>
      <span>Span 1. In the div.
        <span>Span 2. In the span that's in the div.</span>
      </span>
    </div>
    <span>Span 3. Not in a div at all</span>
    

    Specifications

    Specification Status Comment
    CSS Selectors Level 3 Recommendation  
    CSS 2.1 Recommendation  

    Browser compatibility

    Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
    Basic support (Yes) (Yes) 7.0 (Yes) (Yes)
    Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
    Basic support ? ? ? ? ?

    See also

    Document Tags and Contributors

    Contributors to this page: Sheppy
    Last updated by: Sheppy,
    Hide Sidebar