子代选择器

后代选择器和子代选择器的区别在于匹配的层级。

写法匹配范围
A BA 内任何层级的 B
A > BA 的直接子元素 B
<div class="note">
  <p>第一段</p>
  <section><p>第二段</p></section>
</div>
html
.note p { color: gray; }          /* 两段都匹配 */
.note > p { font-weight: bold; }  /* 只匹配第一段 */
css