- 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.
推薦閱讀
- JBoss Weld CDI for Java Platform
- 手機安全和可信應用開發指南:TrustZone與OP-TEE技術詳解
- C語言程序設計實踐教程(第2版)
- Android Jetpack開發:原理解析與應用實戰
- Docker技術入門與實戰(第3版)
- Hands-On Machine Learning with scikit:learn and Scientific Python Toolkits
- C#實踐教程(第2版)
- C#程序設計教程(第3版)
- MySQL入門很輕松(微課超值版)
- Java EE企業級應用開發教程(Spring+Spring MVC+MyBatis)
- Python 3.7從入門到精通(視頻教學版)
- SQL Server 2016 從入門到實戰(視頻教學版)
- C++程序設計教程(第2版)
- Mastering Drupal 8
- 用Python動手學統計學