 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
¡Gracias por tus comentarios!
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla
Awesome!
Completion rate improved to 8.33 Nesting and Structure
Nesting and Structure
Desliza para mostrar el menú
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
¡Gracias por tus comentarios!