A morning on the ridge
A short walking report.
The view
The valley was clear below the trail.
HTML REFERENCE · 05
Page regions tell readers and assistive technology how content is organized. Choose containers for their purpose; their names do not prescribe a particular visual layout.
| Element or attribute | What it means | When to use it |
|---|---|---|
header |
Introductory content for a page or a section. | Use for a title, introduction, or related navigation. A page and an article can each have their own header. |
nav |
A region containing major navigation links. | Use for the main menu or a substantial table of contents, rather than wrapping every small group of links. |
main |
The document’s dominant content. | Use one visible main for the page’s primary subject. Repeated site menus and site-wide footers usually belong outside it. |
section |
A thematic group of related content. | Use when the group has a distinct subject, normally identified by a heading. Do not use it solely as a styling wrapper. |
article |
A self-contained composition that could make sense independently. | Use for a news story, review, or forum post. It can contain its own header, sections, and footer. |
aside |
Content indirectly related to the surrounding content. | Use for a related reading note or a supplementary sidebar. Position alone does not make content an aside. |
footer |
Closing information for its page or nearest sectioning ancestor, such as an article. | Use for authorship, related information, or copyright. It need not appear at the bottom of the screen. |
div / span |
Generic containers without a specific subject or page-region meaning. | Use div to group flow content and span for a phrase when no more meaningful element fits. |
aria-label |
An attribute supplying an accessible name. | Use to distinguish navigation regions with short names, such as “Lesson navigation.” It does not add a visible label. |
aria-labelledby |
An attribute referring to the ID of visible naming text. | Use to name a region from its heading. It must point to an existing ID; it does not generate a heading. |
Header groups introductory content; nav identifies the navigation purpose. Aria-label names the navigation for assistive technology. These containers do not automatically create columns or a menu bar.
<header>
<h2>Trail Notes</h2>
<p>Short descriptions of local walks.</p>
</header>
<nav aria-label="Trail Notes navigation">
<a href="../index.html">HTML Guide</a>
<a href="#walk-report">Walk report</a>
</nav>
Short descriptions of local walks.
This report makes sense as a separate composition. Its header introduces the report, the section groups one topic, and its footer identifies the author. The section is named by its visible heading.
<article id="walk-report">
<header>
<h2>A morning on the ridge</h2>
<p>A short walking report.</p>
</header>
<section aria-labelledby="ridge-view">
<h3 id="ridge-view">The view</h3>
<p>The valley was clear below the trail.</p>
</section>
<footer>
<p>Written by Nikki.</p>
</footer>
</article>
A short walking report.
The valley was clear below the trail.
Article is a good fit for an independent report. Section is a good fit for a subject within it. Neither element automatically chooses the correct heading level for you.
This note is related to the walk report but is not part of the report itself. Aside describes that relationship even if CSS displays it below the main text.
<aside aria-labelledby="reading-note">
<h2 id="reading-note">Related reading</h2>
<p>A trail guide can explain local route names.</p>
</aside>
Div groups these short notes. Span singles out a phrase without calling it a new section. Neither container adds special importance or creates a page landmark.
<div>
<p>Route name: <span>Ridge Loop</span></p>
<p>Area: North valley</p>
</div>
Route name: Ridge Loop
Area: North valley
Main identifies the dominant content of a page. The site introduction and closing author information sit outside it. This example represents the content of a separate page’s body.
<header>Trail Notes</header>
<main>
<h1>Ridge Loop</h1>
<p>A walk above the valley.</p>
</main>
<footer>Written by Nikki.</footer>
The output is an isolated document so its main region remains separate from this lesson’s main region. In your own HTML file, place the example directly inside body. Keep one visible main per document.
Further reading: W3Schools: Page Structure. The explanations and examples here are written for this guide.
Answer in your own words before opening each explanation.
The dominant content unique to the current document, such as its main report or lesson. Repeated site navigation normally sits outside it.
Article represents a composition that could stand on its own. Section groups content around a topic and normally has a heading.
Yes. Those elements can introduce and close the article as well as serve the overall page.
No. It means the content is indirectly related. CSS determines where it appears.
No. Nav is for major navigation regions. A small incidental link group does not always need it.
When a generic grouping is needed and no element with a more specific meaning fits. Use span for a generic phrase within text.
No. Choose heading levels explicitly to reflect the surrounding outline.
The ID of text that names the region, often its visible heading. It must reference an element that actually exists.