Child Selector: element1 > element2

Pattern:

element1 > element2

 

Definition:

The element1 > element2 selector matches every element2 that is the child of element1. A child selector is made up of two or more selectors separated by ">".

 

Examples:

Style every <a> that is the child of <p>.

p > a { padding: 10px; }

Match every <a> element that is a descendant of <em>; the <em> element must be the child of a <p>; and the <p> element must be a descendant of a <div>.

div p > em a { background-color: gold; }
w10schools
2014-11-10 04:42:18
>
Comments
Leave a Comment

Please login to continue.