Nesting of tags is the act of having other tags inside a tag. Most of your defined HTML elements will also have tags inside of them defining other elements. Such tags are known as nested tags.
In the above, the <div> element have inside of it some elements which comprises of another element created with the <p> tag and inside that <p> element is another element, the <b> element. In this case, the <div> tag is the parent tag while the <p> tag is its child. The <p> tag also has a child, the <b> tag.
The importance of understanding the nesting of tags is that it will help you in understanding how to properly close tags whose concept is for you to close the child element first before the parent element.
Study How The Below Was Nested. Identify The Parents & Children
<h1>Welcome To My Webpage</h1>
Copy PRACTICE IT
- Nesting of tags is the process of having a tag inside another. For example, <p><img/></p>.
- A tag created inside another tag is called a nested tag and is a child to the tag it was nested in.
- Building elements involves the nesting of tags to achieve what we want.
- Understanding how to nest tags translates to understanding how to properly close tags because the rule stipulates that a child tag be close before a parent tag.
<div><p><b>Hello Jay</p></div></b> <!-- WRONG -->
<div><p><b>Hello Jay</b></p></div> <!-- CORRECT -->