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:

Element nesting creates a “parent/child” relationship”, as shown here:

Exercises

  1. How many elements do you see here, and what are they?

    <div> This lesson about <b>HTML</b> is 
    <em>very</em> interesting.</div>
    
  2. In the example above, what is the parent of the b element?

  3. What relationship does the em element have to the div element?