mozilla
Your Search Results

    Descendant selectors

    Summary

    The combinator (that's meant to represent a space, or more properly one or more whitespace characters) combines two selectors such that the combined selector matches only those elements matching the second selector for which there is an ancestor element matching the first selector. Descendant selectors are similar to child selectors, but they do not require that the relationship between matched elements be strictly parent-child.

    Syntax

    selector1 selector2 { style properties }
    

    Example

    span { background-color: white; }
    div span { background-color: DodgerBlue; }
    
    <div>
      <span>Span 1.
        <span>Span 2.</span>
      </span>
    </div>
    <span>Span 3.</span>
    

    Specifications

    Specification Status Comment
    Selectors Level 3
    The definition of 'descendant combinator' in that specification.
    Recommendation  
    CSS Level 2 (Revision 1)
    The definition of 'descendant selectors' in that specification.
    Recommendation  
    CSS Level 1
    The definition of 'contextual selectors' in that specification.
    Recommendation Initial definition

    Browser compatibility

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

    Document Tags and Contributors

    Last updated by: MusikAnimal,