 Nesting and Structure
Nesting 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 mainelement per page, and do not nest it insideheader,footer,article, orsectionelements;
- Use sectionelements to group related content withinmainor within anarticle;
- Nest articleelements insidesectionwhen you have multiple, self-contained pieces of content within a section;
- Use asidefor tangentially related content, such as tips, links, or sidebars, and place it withinmain,article, or evensectionas appropriate;
- Avoid placing headerorfooterelements directly insideasideunless the aside itself represents a complete, standalone section.
Note
A common mistake is to nest
mainelements inside each other, or to putmaininside aheaderorfooter. Another error is to usesectionorarticleelements without a clear reason—use them only when the content has its own heading or could stand on its own.
index.html
Takk for tilbakemeldingene dine!
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
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 Nesting and Structure
Nesting and Structure
Sveip for å vise menyen
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 mainelement per page, and do not nest it insideheader,footer,article, orsectionelements;
- Use sectionelements to group related content withinmainor within anarticle;
- Nest articleelements insidesectionwhen you have multiple, self-contained pieces of content within a section;
- Use asidefor tangentially related content, such as tips, links, or sidebars, and place it withinmain,article, or evensectionas appropriate;
- Avoid placing headerorfooterelements directly insideasideunless the aside itself represents a complete, standalone section.
Note
A common mistake is to nest
mainelements inside each other, or to putmaininside aheaderorfooter. Another error is to usesectionorarticleelements without a clear reason—use them only when the content has its own heading or could stand on its own.
index.html
Takk for tilbakemeldingene dine!