Note header and footer can be used for the entire page or within an article/section element. A page can have multiple headers and footers in different contexts.
Note There must be only one visible main element per page. It should not be nested inside header, footer, nav, article, or aside. Skip-navigation links typically target main.
main contentprimary contentmain elementpage content
Section & Article
Syntax
<section>...</section><article>...</article>
Example
<main><section><h2>Latest Articles</h2><article><h3>Understanding Flexbox</h3><p>A practical guide to flexible layouts...</p></article><article><h3>Grid Layout Patterns</h3><p>Common patterns for CSS Grid...</p></article></section></main>
Note An article is a self-contained piece of content that could be independently distributed (blog post, comment, product card). A section is a thematic grouping of content. Both should generally include a heading.
<main><article><h2>Web Performance Guide</h2><p>Core Web Vitals measure real-world user experience...</p><aside><h3>Related Resources</h3><ul><li><ahref="/caching">Caching Strategies</a></li><li><ahref="/images">Image Optimization</a></li></ul></aside></article></main>
Note aside represents content tangentially related to its parent. When used at the page level it acts as a sidebar. Inside an article, it represents a pullquote or supplementary info.
<details><summary>How do I reset my password?</summary><p>Go to the login page and click "Forgot Password". Enter your email address and we will send you a reset link within 5 minutes.</p></details><detailsopen><summary>System Requirements</summary><ul><li>64-bit operating system</li><li>4 GB RAM minimum</li></ul></details>
Note This creates a native collapsible section with no JavaScript needed. The open attribute shows the content expanded by default. Style the summary's marker with ::marker or list-style.
<dialogid="confirmDialog"><h2>Confirm Deletion</h2><p>This will permanently remove the item. Continue?</p><formmethod="dialog"><buttonvalue="cancel">Cancel</button><buttonvalue="confirm">Delete</button></form></dialog><!-- Open with: document.getElementById('confirmDialog').showModal() -->
Note Use showModal() to open with a backdrop that traps focus (accessible). Use show() for a non-modal popup. The form method="dialog" approach closes the dialog and sets its returnValue to the button's value.
Note Content inside template is not rendered, not visible, and not queried by selectors. It serves as a blueprint for JavaScript-generated elements. Clone its content with cloneNode(true).