官术网_书友最值得收藏!

  • Mastering CSS
  • Rich Finelli
  • 138字
  • 2021-07-08 09:45:54

Parent, child, and sibling elements

Let's go to our HTML and take a peek at this nicely nested HTML code in the secondary-section. So basically, what we have here is a section tag and three div tags that are inside of that section:

<section>
<div>
<figure>
<img src="images/octopus-icon.png" alt="Octopus">
</figure>
<h2 class="column-title">The Octopus</h2>
<p>Lorem ipsum dolor...</p>
<a href="#" class="button">Tenticals</a>
</div>
<div>
<figure>
<img src="images/crab-icon.png" alt="Crab">
</figure>
<h2 class="column-title">The Crab</h2>
<p>Lorem ipsum dolor...</p>
<a href="#" class="button">Crabby</a>
</div>
<div>
<figure>
<img src="images/whale-icon.png" alt="Whale">
</figure>
<h2 class="column-title">The Whale</h2>
<p>Lorem ipsum dolor...</p>
<a href="#" class="button">Stuart</a>
</div>
</section>

So <div> is the child element of <section>, while <section> is the parent. In other words, <div> is the descendant of <section>, <section> is the ancestor of <div>. <figure> is also a descendant of <section>, and <img> is a descendant of <section>. Note that <figure>, <h2>, and <p> are on the same level of the HTML so they are siblings, and they are also all descendants of <section>. That's as complicated as it gets; there are no uncles, no aunts, and no third cousins.

主站蜘蛛池模板: 镇雄县| 洞头县| 临猗县| 巫溪县| 安岳县| 湘潭市| 商洛市| 卓尼县| 嘉鱼县| 阿鲁科尔沁旗| 缙云县| 依安县| 乌鲁木齐县| 体育| 南溪县| 吉林市| 雷州市| 民丰县| 高淳县| 济源市| 乐亭县| 五家渠市| 全南县| 邵东县| 仁布县| 苏尼特左旗| 昭平县| 镇巴县| 康保县| 二连浩特市| 靖宇县| 全南县| 鸡西市| 尼勒克县| 台北县| 津南区| 宜良县| 云浮市| 长葛市| 肥东县| 会东县|