Parents, Children, Descendants, and Siblings

Description

HTML elements defines relationships with the other elements in an HTML document.

Parent vs Child

An element that contains another element is the parent of the second element.


<!DOCTYPE HTML>
<html>
    <head>
        <!--  metadata goes here   -->
        <title>Example</title>
    </head>
    <body>
       This is the <code>content</code>.
    </body>
</html>

The body element is the parent to the code element, because the code element is contained between the start and end tags of the body element.

The code element is a child of the body element.

An element can have multiple children, but only one parent.

Descendents

The html element contains the body element, which contains the code element.

The body and code elements are descendents of the html element.

Only the body element is a child of the html element.

Children are direct descendants.

Elements that share the same parent are known as siblings.

The head and body elements are siblings.





















Home »
  HTML CSS »
    HTML »




HTML Introduction
HTML Document
HTML Section
HTML Group Content
HTML Text Marker
HTML Table
HTML Form
HTML Embed