Content · Web Development · HTML

HTML Nesting Rules: Parents, Children, and Siblings

Nesting means placing one element inside another. The outer element is the parent, and the element directly inside it is a child. Two children sharing one parent are siblings.

1 views Published Oct 19, 2026 Updated Oct 19, 2026 Admin

Nesting means placing one element inside another. The outer element is the parent, and the element directly inside it is a child. Two children sharing one parent are siblings.

What You Need to Know


Close the inner element before closing its parent. Some elements also have restrictions about which children they may contain, such as a list requiring li items.

The goal is not to collect as many tags as possible. Pick the element that best describes what the content really is.

Example: See It in Action


Add this example to the appropriate part of a practice HTML page. Read each line before you open the page in your browser.

This is a short HTML fragment. To try it as a webpage, put it inside the body element of a complete HTML document.

<article>
    <h2>My weekend</h2>
    <p>I visited the <strong>science museum</strong>.</p>
    <p>We had a great day.</p>
</article>

Let’s Understand the Example


  • Article marks a piece that could make sense on its own, such as a news post or recipe.
  • An h2 starts a major section beneath the page topic.
  • A p groups a paragraph of related text. Start another paragraph for a new thought.

You should see a readable heading and its related content. The heading level tells readers how the ideas fit together, not merely how large the letters look.

What Should You See?


The page should display “My weekend” as a heading, followed by its related content. Change the heading text and refresh the browser to see the result.

Read only the headings, from top to bottom. Do they tell a sensible story? If not, move sections or choose levels that match the content.

Try It Yourself


  1. Draw a quick tree for the article, its two paragraphs, and the strong element.
  2. Save your changes, open or refresh the page, and compare the result with the original example.
  3. Tell a friend what your change did. If you are not sure, undo it, refresh the page, and compare.

Common Beginner Mistakes


  • Crossing closing tags, as in <strong><em>text</strong></em>.
  • Avoid picking tags just for their default bold, italic or spaced appearance. Use CSS for presentation.

Key Takeaways


  • Nesting means placing one element inside another.
  • Article marks a piece that could make sense on its own, such as a news post or recipe.
  • Close the inner element before closing its parent. Some elements also have restrictions about which children they may contain, such as a list requiring li items.
Share this resourceSend this page to someone who may find it useful.