Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Nesting and Structure | Understanding Semantic HTML
Build Meaningful and Accessible Web Pages

bookNesting and Structure

When building a web page, how you nest semantic layout elements affects both the clarity of your code and the accessibility of your content. Proper nesting means placing elements within each other in a way that reflects the logical structure of your page. For example, your main content should be inside the main element, and distinct sections of content belong in section elements. If you have a news article, that might go inside an article element, which itself could be nested within a section. Related content that is not the main focusβ€”such as a sidebarβ€”should be placed in an aside.

Here are some common patterns for nesting semantic layout elements:

  • Place only one main element per page, and do not nest it inside header, footer, article, or section elements;
  • Use section elements to group related content within main or within an article;
  • Nest article elements inside section when you have multiple, self-contained pieces of content within a section;
  • Use aside for tangentially related content, such as tips, links, or sidebars, and place it within main, article, or even section as appropriate;
  • Avoid placing header or footer elements directly inside aside unless the aside itself represents a complete, standalone section.

Note

A common mistake is to nest main elements inside each other, or to put main inside a header or footer. Another error is to use section or article elements without a clear reasonβ€”use them only when the content has its own heading or could stand on its own.

index.html

index.html

copy
question mark

Which of the following statements about nesting semantic layout elements is correct?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 4

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Suggested prompts:

Can you give me an example of properly nested semantic elements?

What are some common mistakes to avoid when nesting these elements?

How does proper nesting improve accessibility?

Awesome!

Completion rate improved to 8.33

bookNesting and Structure

Swipe to show menu

When building a web page, how you nest semantic layout elements affects both the clarity of your code and the accessibility of your content. Proper nesting means placing elements within each other in a way that reflects the logical structure of your page. For example, your main content should be inside the main element, and distinct sections of content belong in section elements. If you have a news article, that might go inside an article element, which itself could be nested within a section. Related content that is not the main focusβ€”such as a sidebarβ€”should be placed in an aside.

Here are some common patterns for nesting semantic layout elements:

  • Place only one main element per page, and do not nest it inside header, footer, article, or section elements;
  • Use section elements to group related content within main or within an article;
  • Nest article elements inside section when you have multiple, self-contained pieces of content within a section;
  • Use aside for tangentially related content, such as tips, links, or sidebars, and place it within main, article, or even section as appropriate;
  • Avoid placing header or footer elements directly inside aside unless the aside itself represents a complete, standalone section.

Note

A common mistake is to nest main elements inside each other, or to put main inside a header or footer. Another error is to use section or article elements without a clear reasonβ€”use them only when the content has its own heading or could stand on its own.

index.html

index.html

copy
question mark

Which of the following statements about nesting semantic layout elements is correct?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 4
some-alt