Information about cookies on this page

Our website uses cookies to ensure the functionality of the website, to collect and analyze information about the performance and usage of the website. Privacy Policy

  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in
  
  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in

Nesting and Family Relationships

Let's look at the page we have built so far:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>My First Page</title>
	</head>
	<body>
	</body>
</html>

Some elements are inside other elements: head and body are inside html, and meta and title are inside head. Remember that the content of an element can be other elements. When we put an element inside another one, we say that we nest it.

To describe how nested elements relate to each other, we borrow words from the family:

  • A parent is the element that another element is directly inside. html is the parent of head and body.
  • A child is an element directly inside another element. title is a child of head.
  • Siblings are elements with the same parent. head and body are siblings, and so are meta and title.

Now let's give body some children, so that something finally shows up on our page. Besides the h1 heading, we'll use the p element, which stands for paragraph. We'll look at paragraphs more closely in the next lesson.

Instructions

  1. 1

    Inside the body element, create an h1 element with a heading, for example Hello world!. The h1 element will be a child of body.

  2. 2

    Below the h1 element, create its sibling: a p element with a sentence, for example This is my first web page.

Back

7/9

  1. 1. Introduction to HTML
  2. 2. HTML Element Structure
  3. 3. Document Type Declaration
  4. 4. Page Skeleton
  5. 5. Page Title and Character Set
  6. 6. Quiz: The Page Title
  7. 7. Nesting and Family Relationships
  8. 8. Indentation
  9. 9. Recap
Next

Try it yourself

Do this exercise right here in your browser. No account needed.