Concepts and Entities
- HTML5 Sectioning Elements: Semantic tags used to define specific, logical parts of a web page's structure.
- ARIA Landmarks: Points on a page that assistive technologies use to help users identify and navigate high-level regions.
- Semantic Elements: Tags that clearly describe their meaning to both the browser and the developer.
<main>: An element containing the unique, primary content of a document, excluding repeated site-wide elements.<article>: A tag for independent, self-contained content that remains meaningful if distributed separately from the site.<section>: A generic element used for thematic groupings of content, typically identified by a heading.<nav>: A section specifically intended for major blocks of navigation links.<aside>: A container for content that is tangibly related to the main text but could be considered separate, like a sidebar.<header>: A container for introductory content, logos, or primary navigational links.<footer>: A section for information about its parent element, such as authorship, copyright, or sitemaps.<address>: An element specialized for providing contact information for the author or owner of a document or article.<figure>: A tag that specifies self-contained content like illustrations, diagrams, or photos.<figcaption>: An element that provides a visible caption or legend for a<figure>.
HTML5 sectioning elements are semantic tags that organize web content into logical, identifiable regions. These elements describe their purpose to browsers, search engines, and assistive technologies, replacing generic "div soup" with meaningful architecture.
Proper structure ensures that [a semantic web allows data to be shared and reused across applications, enterprises, and communities] (W3Schools).
What are HTML5 Sectioning Elements?
Sectioning elements are a subset of semantic tags that define the outline of a document. Unlike non-semantic elements like <div> and <span>, which tell the browser nothing about their content, sectioning tags like <nav> or <article> clearly define the nature of the information they hold.
These elements often double as ARIA landmarks. Landmark roles help users of assistive technology (AT) navigate a page efficiently by jumping between major areas like the navigation, main content, and footer.
Why HTML5 Sectioning Elements matter
Using semantic sectioning provides several technical and practical benefits:
- Improved Accessibility. Many sectioning elements define landmarks by default. This makes it easier for screen reader users to skip through content or find specific regions.
- SEO and Machine Readability. Search engines use these tags to understand the document outline and the relative importance of different content blocks.
- Developer Efficiency. Semantic code is easier to scan and maintain. It reduces the need for frequent class names (like
<div class="nav">) to identify page parts. - Better Search Results Context. [According to the W3C, headings within sections assist in providing context for search engine results] (MDN).
How HTML5 Sectioning Elements work
Sectioning elements create a hierarchy by nesting content within specific tags. When browsers render these tags, they associate them with implicit ARIA roles. For example, the <nav> element is automatically treated as a "navigation" landmark.
AT users can use keyboard shortcuts to jump from landmark to landmark. If a page is built entirely of <div> tags, the AT user may have to listen to the entire page to find the content they need. By wrapping contact info in a <footer> or the primary text in <main>, you provide "hooks" for these programs to identify the page’s structure.
Core Sectioning Elements
| Element | Use Case | Landmark Behavior |
|---|---|---|
<main> |
The primary, unique content of the page. Only one per page. | Always a landmark. |
<article> |
Independent content like blog posts, comments, or product cards. | Not a landmark. |
<section> |
A thematic grouping, such as chapters or an introduction. | Landmark ONLY if it has an accessible name (label/title). |
<nav> |
Major blocks of navigation links. | Always a landmark. |
<aside> |
Tangential information, sidebars, or pull quotes. | Always a landmark. |
<header> |
Introductory content, headings, or logos. | Landmark if it is a direct child of <body>. |
<footer> |
Copyright info, sitemaps, or contact links. | Landmark if it is a direct child of <body>. |
Best practices
Use <main> for unique content.
All content inside <main> should be unique to that specific page. Do not include repeated elements like search boxes, logos, or global navigation within this tag.
Identify sections with headings.
Every <section> should typically include an <h1> through <h6> element. This provides a title for the section and helps define the document outline for both SEO and accessibility.
Keep <article> self-contained.
Use <article> for content that would still make sense if it were syndicating as a standalone piece, such as a newspaper article or a forum post.
Be selective with <nav>.
Not every group of links needs a <nav> tag. Use it only for major navigation blocks. For example, a list of social media icons in the footer usually does not require its own <nav> wrapper.
Reserve <address> for contact info.
Only use the <address> tag to provide contact information (like an email or author URL) for the page or an article. Do not use it for random postal addresses mentioned in the text.
Common mistakes
Mistake: Using <section> as a styling wrapper.
Fix: If you only need an element to apply CSS backgrounds or padding, use a <div>. A <section> implies a thematic grouping of content.
Mistake: Using more than one <main> element.
Fix: Ensure each document contains exactly one <main> tag. It should not be nested inside <article>, <aside>, <header>, or <footer>.
Mistake: Nesting <header> inside another <header>.
Fix: A <header> cannot be a descendant of another <header>, a <footer>, or an <address> element.
Mistake: Relying on sectioning elements for older screen readers.
Fix: While modern browsers support these tags, older software may not. You can add role="main" to a <main> tag or role="navigation" to a <nav> tag to ensure broader compatibility.
Examples
Blog Post Structure
A typical blog post uses nesting to show relationships between the post and its metadata.
<main>
<article>
<header>
<h1>Understanding Semantic HTML</h1>
<p>Published: October 2023</p>
</header>
<p>Semantic tags improve your site architecture...</p>
<section>
<h2>Benefit 1: Accessibility</h2>
<p>Details about landmarks...</p>
</section>
<footer>
<address>Contact the author at <a href="mailto:[email protected]">[email protected]</a></address>
</footer>
</article>
</main>
Application UI Controls
In a web application, <section> might be used without a heading for a toolbar or action area.
<section title="Message Controls">
<button class="reply">Reply</button>
<button class="del">Delete</button>
</section>
FAQ
Can I nest an <article> inside a <section>?
Yes. You can nest <article> within <section> or vice versa. The choice depends on the content; if several independent articles are grouped by a single theme, a <section> containing multiple <article> tags is appropriate.
Is a <form> considered a landmark?
Yes, in most browser and assistive technology combinations, a <form> defines a landmark. However, it can be safely nested inside other landmarks like <main> or <aside>.
What is the difference between <main> and generic landmarks?
<main> identifies the primary content unique to that page. Landmarks like <header> or <nav> often contain "boilerplate" content that repeats across the entire website.
When should I use <div> instead of a sectioning element?
Use a <div> when you need a generic container for styling, layout, or scripting purposes that does not add semantic meaning to the document outline.
Do browsers support these elements? Yes. [Google Chrome, for example, has supported these standards since its release in 2008] (W3Schools). For the best experience across all users, most experts suggest using these tags alongside ARIA roles where support may be inconsistent in older software.