html: nesting
HTML elements inside one another
Perhaps read these first
You may find it helpful to read the following pages before this one.
- html
Nesting of HTML elements
HTML elements can be nested inside one another. For example:
<p>This food is <em>very</em> hot!</p>
That example has two HTML elements:
- An
emelement with contentvery - A
pelement with content:This food is <em>very</em> hot
Element nesting creates a “parent/child” relationship”, as shown here:
- In this case, since this
emelement is contained entirely within thispelement, we say that thepelement is the parent of theemelement. - Conversely, the
emelement shown here is the child of thepelement.
Exercises
-
How many elements do you see here, and what are they?
<div> This lesson about <b>HTML</b> is <em>very</em> interesting.</div> -
In the example above, what is the parent of the
belement? -
What relationship does the
emelement have to thedivelement?