Nested Elements

An HTML element can contain another element. They make "Nested Elements".



Nested Elements

An HTML element can contain another element. They make Nested Elements.

See the main structure of an HTML document.

<!DOCTYPE html>
<html>
  <head>
    <title>Page Title</title>
  </head>
  <body>
       <p>This is a paragraph</p>
       <p>This is another <b>paragraph</b></p>
   </body>
</html>

View in Code Editor

The <html> element contains all other elements. (this is root element)

Within this element, there are <head> and <body> elements. Therefore, the contents of the <html> element are the <head> and <body> elements.

Within the <head> element there is the <title> element that specifies the "title" of the HTML document. Its content is a plain text and there is no other element inside it. (<title> element could not contains other elements.)

The contents of the <body> element are two other elements, of the type of paragraph.

Within the first paragraph element, there is only plain text and no element exists. And inside the second paragraph element there is a plain text along with a <b> element. (The <b> element displays bold text.)

<< : Empty Elements HTML Attributes : >>