CSS Child Selector

CSSWeb DevelopmentFront End Technology

Use the child selector, if you want to select all elements immediate children of a specified element.

div > p

Example

You can try to run the following code to implement CSS Child Selector

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <style>
         div > p {
            background-color: orange;
         }
      </style>
   </head>
   <body>
      <div>
         <p>Para 1 in the div.</p>
         <!-- This is not a Child -->
         <span><p>Para 2 in the div.</p></span>
      </div>
      <p>Para 3 outside the div.</p>
   </body>
</html>

Output

raja
Published on 08-May-2018 12:28:37
Advertisements