DEV Community

Cover image for Most Developers Ignore the <main> Tag — But It Fixes a Big Accessibility Problem
Pawar Shivam
Pawar Shivam

Posted on

Most Developers Ignore the <main> Tag — But It Fixes a Big Accessibility Problem

A small semantic HTML element that improves accessibility, page structure, and SEO clarity.

A Tag Many Developers Forget

Most HTML pages still look like this:

<div class="container">
  <div class="content">
    <h1>Article Title</h1>
    <p>Main content goes here</p>
  </div>
</div>
Enter fullscreen mode Exit fullscreen mode

This works visually, but it hides something important: the actual main content of the page.

Modern HTML already provides a semantic solution:

<main>
  <h1>Article Title</h1>
  <p>Main content goes here</p>
</main>
Enter fullscreen mode Exit fullscreen mode

The <main> element tells browsers and assistive technologies exactly where the primary content of the page begins.


What the <main> Tag Actually Does

The <main> tag represents the dominant content of a webpage.

It excludes things like:

  • navigation menus
  • headers
  • sidebars
  • footers

Instead, it highlights the central content users came to read or interact with.

Example page structure:

<header>
  <nav>
    <!-- navigation links -->
  </nav>
</header>

<main>
  <article>
    <h1>Semantic HTML Matters</h1>
    <p>This is the primary content of the page.</p>
  </article>
</main>

<footer>
  <!-- footer links -->
</footer>
Enter fullscreen mode Exit fullscreen mode

This structure makes your page easier to understand for both browsers and assistive technologies.


Why <main> Is Important for Accessibility

Assistive technologies such as screen readers rely on semantic landmarks to navigate webpages.

When a page includes a <main> element, screen readers can quickly jump to the primary content.

Users can skip repetitive sections like:

  • navigation menus
  • headers
  • sidebars

This significantly improves usability for people using assistive tools.

Accessibility tools often allow users to jump directly to the main landmark region.


Why Many Developers Still Ignore It

There are a few reasons developers overlook the <main> tag:

  • older habits from pre-HTML5 development
  • heavy reliance on <div> containers
  • focusing more on CSS and JavaScript than HTML semantics

But semantic HTML improves both readability and structure with almost no extra effort.


A Clean Semantic Layout Example

A modern webpage layout should look something like this:

<body>

<header>
  <nav>
    <a href="/">Home</a>
    <a href="/articles">Articles</a>
  </nav>
</header>

<main>
  <h1>Welcome to My Blog</h1>
  <p>This section contains the main content of the page.</p>
</main>

<footer>
  <p>© 2026</p>
</footer>

</body>
Enter fullscreen mode Exit fullscreen mode

This structure makes the document hierarchy clear.

It improves:

  • accessibility
  • semantic clarity
  • maintainability

Important Rule: Use Only One <main>

A page should contain only one <main> element.

This ensures there is a clear, single location for the primary content.

Example of incorrect usage:

<main>
  <section>Content</section>
</main>

<main>
  <section>More content</section>
</main>
Enter fullscreen mode Exit fullscreen mode

Only one main region should exist per page.


Final Thought

Frontend development often focuses on frameworks like React, performance optimizations, and complex UI systems.

But strong web applications still depend on good HTML structure.

A simple semantic tag like <main> can make your website:

  • more accessible
  • easier to navigate
  • better structured

Sometimes the smallest HTML improvements create the biggest impact.

Top comments (0)