The basic sub-element selector can only search downwards one level at a time, and cannot cross
HTML code:
<p> this is my <strong><i>w</i>eb</strong> page. </p>
CSS code:
p>strong { color: purple; } p>strong>i { font-size: 50px; }
1. Compared with the descendant selector, the child element selector can only select elements that are child elements of an element.
2. The sub-element selector uses the greater than sign ">" as the connector.
Example 1:
<html> <head> <style type="text/css"> h1 > strong { color: red; } </style> </head> <body> <h1>This is <strong>very</strong> <strong>very</strong> important.</h1> <h1>This is <em>really <strong>very</strong></em> important.</h1> </body> </html>
##Example 2
<html> <head> <style type="text/css"> table.company td > p { color: red; } </style> </head> <body> <table class='company'> <tr> <td> <p>hello</p> </td> </tr> </table> <table> <tr> <td> <p>world</p> </td> </tr> </table> </body> </html>