Example

Combinators - child Selectors

HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link name="favicon" type="image/x-icon" href="https://skillzam.com/uploads/system/e353194f3b7cd1b75d69c3ab88041985.png" rel="shortcut icon" />
    <title>Combinators: child Selectors</title>

    <style>

        /* child selector */
        div > p {
            background-color: cyan;
        }

    </style>

</head>
<body>
<!-- 
    child selector: Example: div > p	
    Selects all <p> elements where the parent is a <div> element
-->

    <h1>Demo: Combinators - child selectors</h1> 

    <p>para1 :Lorem ipsum dolor sit amet consectetur adipisicing elit. Eum, necessitatibus.</p>
    
    <div>
        <p>para2 :Lorem ipsum dolor sit amet consectetur adipisicing elit. Eum, necessitatibus.</p>
        <p>para3 :Lorem ipsum dolor sit amet consectetur adipisicing elit. Eum, necessitatibus.</p>
        <section>      
            <p>para4 :Lorem ipsum dolor sit amet consectetur adipisicing elit. Eum, necessitatibus.</p>
        </section>
    </div>
    
    <p>para5 :Lorem ipsum dolor sit amet consectetur adipisicing elit. Eum, necessitatibus.</p>
    <p>para6 :Lorem ipsum dolor sit amet consectetur adipisicing elit. Eum, necessitatibus.</p>
    
    <div>
        <p>para7 :Lorem ipsum dolor sit amet consectetur adipisicing elit. Eum, necessitatibus.</p>
        <p>para8 :Lorem ipsum dolor sit amet consectetur adipisicing elit. Eum, necessitatibus.</p>
    </div>
    
    <p>para9 :Lorem ipsum dolor sit amet consectetur adipisicing elit. Eum, necessitatibus.</p>
    <p>para10 :Lorem ipsum dolor sit amet consectetur adipisicing elit. Eum, necessitatibus.</p>
    <p>para11 :Lorem ipsum dolor sit amet consectetur adipisicing elit. Eum, necessitatibus.</p>
    
</body>
</html>

Output

View original