Learning Tips | Published Nov 16, 2026 | 8 min read

Semantic HTML and Page Landmarks

Learn when to use main, nav, article, section, and div, how landmarks support navigation, and how to label repeated page regions.

Diagram of semantic HTML landmarks with a header, separately named navigation areas, main content, article, labelled section and footer

Semantic HTML gives browsers and assistive technologies meaningful structure to work with. Replacing every element with a div can make a page harder to navigate and maintain, even when it looks correct. This guide shows how to choose native elements, map a page into landmarks, and avoid common accessibility mistakes.

What semantic HTML adds

A div is a generic container. It is useful when you need a wrapper for styling or scripting and no more specific element fits. Elements such as main, nav, article, and button communicate purpose through built-in browser semantics. That helps browsers expose the right roles and behavior to assistive technologies, and gives other developers clearer markup to read.

Semantics do not replace visual design or JavaScript. They describe what a part of the document is. CSS can still control its appearance, and JavaScript can still enhance interaction.

Start with the page's major regions

For a typical page, identify the site-wide header, primary navigation, unique main content, and footer. Use the HTML elements that match those roles:

<body>
  <header>
    <a href="/">Site name</a>
  </header>

  <nav aria-label="Primary">
    <a href="/courses">Courses</a>
    <a href="/blog">Blog</a>
  </nav>

  <main>
    <article>
      <h1>A page-specific heading</h1>
      <p>The main information for this page goes here.</p>
    </article>
  </main>

  <footer>
    <p>Contact and site information</p>
  </footer>
</body>

A main element marks the dominant content of the document. In an ordinary page, use one visible main element and keep it outside header, navigation, and footer regions. The HTML standard defines nav for sections containing major navigation links; a short group of footer links does not always need its own nav.

Use a header and footer according to their context. At the page level they can identify site-wide introductory and closing material. Inside an article or section, they can instead introduce or close that section. A header is not automatically the page's banner landmark if it is nested inside sectioning content.

Choose article, section, and div deliberately

  • article: a self-contained composition that could make sense on its own, such as a blog post, news item, or forum post.
  • section: a thematic grouping of related content, usually with a heading. It is not a generic wrapper for every block.
  • div: a generic container when no more meaningful element applies.
  • aside: content related to the surrounding content but separate from its main flow, such as a related-links panel.

These elements express structure, but not every one creates a landmark. For example, a section is exposed as a region landmark when it has an accessible name. Do not add a label to every section automatically: reserve named regions for sections important enough to navigate to, and make each label clear.

<section aria-labelledby="schedule-heading">
  <h2 id="schedule-heading">How to plan your study week</h2>
  <p>Group related lessons and leave time for practice.</p>
</section>

Here the visible heading supplies the section's accessible name. If a section is only a styling wrapper and does not form a meaningful thematic group, use a div instead.

Give repeated landmarks useful names

A page can contain more than one navigation area, such as site navigation and a table of contents. Assistive technology users may encounter both as navigation landmarks, so label them when their purposes differ:

<nav aria-label="Primary">...</nav>
<nav aria-label="On this page">...</nav>

Use concise labels that distinguish the destinations. When two landmarks have the same role and similar content, a name can help users tell them apart. Avoid repeating the word “navigation” in every label unless it adds clarity; the landmark role already conveys that information.

Prefer native HTML elements over adding ARIA roles that duplicate their built-in meaning. For instance, <main> already exposes the main landmark; adding role="main" is unnecessary in ordinary HTML. ARIA is useful when native HTML does not provide the needed semantics, but it should not override correct native elements.

Use native controls for interaction

Use <a> for navigation to another URL or location, and <button> for an action such as opening a dialog or submitting a control. A clickable div does not gain keyboard behavior, focus handling, or a meaningful role just because a click listener was attached.

<a href="/courses">Browse courses</a>
<button type="button">Show filters</button>

For a form, associate every field with a label and use the appropriate input type. Add an accessible name to a form only when users need to distinguish it as a landmark, such as when a page has several major forms. Search forms can use the native search element where supported by the document's HTML target; check project browser requirements before adopting newer markup.

Keep headings and landmarks in sync

Landmarks help people move between broad regions; headings help them scan the content within a region. Give the page a clear main heading, then use headings to describe the sections that follow. Choose heading levels by document structure rather than their default font size; CSS can style a correctly ordered heading to look however the design requires.

Do not rely on landmark tags alone to create an outline. A section still needs an informative heading for visual readers, and a heading does not replace a landmark when a page region needs one. Check that the labels and headings describe the same content instead of creating conflicting names.

A practical review checklist

  1. Can you point to the unique primary content and wrap it in one page-level main?
  2. Are navigation elements reserved for meaningful groups of major links?
  3. Does each article stand on its own, and does each section group related content with a heading?
  4. Are repeated landmarks distinguishable with concise accessible names?
  5. Are actions buttons and destinations links, with native keyboard behavior?
  6. Do heading levels describe the content hierarchy, independent of visual styling?
  7. Have you checked the rendered accessibility tree and tested keyboard navigation, rather than relying on source appearance alone?

Automated accessibility tools can catch some structural issues, but a quick keyboard and screen-reader check is still useful. Confirm that landmark navigation is not cluttered with many redundant regions and that names make sense out of context.

Common mistakes to avoid

  • Using section as a synonym for div without a thematic heading or purpose.
  • Wrapping every group of links in nav, including small lists that are not major navigation.
  • Adding role values that simply repeat native HTML semantics.
  • Using a clickable div instead of a link or button.
  • Creating many named landmarks that make navigation harder to scan.
  • Using heading levels only to get a desired font size.

Conclusion

Good semantic markup starts by describing the content and interaction, then choosing the native element that expresses that meaning. Use landmarks for major page regions, headings for the structure inside those regions, and generic containers only when no more specific element fits. This gives your page a clearer structure while preserving flexibility for styling and future changes.

Further reading

Want a structured Java learning path?

Explore Jaipur Engineers course options to connect Java fundamentals, debugging, backend development and project practice in a guided learning plan.

Explore the Java program   Ask for course guidance