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

  • 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.

主站蜘蛛池模板: 西盟| 辉南县| 东莞市| 扶沟县| 开原市| 玉山县| 塘沽区| 博兴县| 青龙| 本溪市| 崇州市| 繁峙县| 蓝山县| 亚东县| 庆城县| 根河市| 珠海市| 钦州市| 宜宾县| 永新县| 江油市| 资溪县| 公主岭市| 桓台县| 安图县| 曲水县| 威海市| 新乡县| 新余市| 普洱| 开阳县| 抚松县| 武胜县| 肇州县| 芷江| 沧州市| 武汉市| 桓台县| 安康市| 屏南县| 林芝县|