- 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.
推薦閱讀
- 從程序員到架構師:大數據量、緩存、高并發、微服務、多團隊協同等核心場景實戰
- 小程序開發原理與實戰
- 第一行代碼 C語言(視頻講解版)
- RealSenseTM互動開發實戰
- Citrix XenServer企業運維實戰
- Hands-On Neural Network Programming with C#
- 零代碼實戰:企業級應用搭建與案例詳解
- Python自然語言理解:自然語言理解系統開發與應用實戰
- Learning Bootstrap 4(Second Edition)
- Applied Deep Learning with Python
- Keil Cx51 V7.0單片機高級語言編程與μVision2應用實踐
- 產品架構評估原理與方法
- Thymeleaf 3完全手冊
- jQuery基礎教程(第4版)
- Spring Microservices