Content · Web Development · HTML

HTML <main> Element: Primary Document Content

Main marks the document's primary content, the part visitors came to read. Typical pages should have one visible main landmark.

1 views Published Oct 19, 2026 Updated Oct 19, 2026 Admin

Main marks the document's primary content, the part visitors came to read. Typical pages should have one visible main landmark.

What You Need to Know


Do not put site-wide repeated navigation inside main when it is not part of the page's unique story. A clear main region makes skip links more useful.

Example: See It in Action


Take a look at this small piece of HTML. You can use it in a practice document and change the text to make it your own.

This is a short HTML fragment. To try it as a webpage, put it inside the body element of a complete HTML document.

<header>
    <nav aria-label="Main"><a href="index.html">Home</a>
    </nav>
</header>
<main id="main-content">
    <h1>Today's News</h1>
    <p>Stories appear here.</p>
</main>
<footer>
    <p>Contact us</p>
</footer>

Let’s Understand the Example


  • Main identifies the central content of the page; it should not be duplicated as separate visible main landmarks.
  • Header introduces a page or section, often with a title and navigation.
  • Nav identifies a major collection of navigation links.
  • Aria-label supplies an accessible name when a visible label is unavailable or inadequate.
  • Href contains the destination of a link. A value starting with # points to an id on the same page.
  • Id gives one element a unique name within the page, so a link, label, or script can point to it.

The first example link points to index.html. Check whether that destination exists relative to the document. A link changes where readers go; it does not perform an action such as saving a form.

What Should You See?


The page should display “Today's News” as a heading, followed by its related content. Change the heading text and refresh the browser to see the result.

Read only the headings, from top to bottom. Do they tell a sensible story? If not, move sections or choose levels that match the content.

Try It Yourself


  1. Move shared navigation outside main and keep the article content inside.
  2. Save your changes, open or refresh the page, and compare the result with the original example.
  3. Tell a friend what your change did. If you are not sure, undo it, refresh the page, and compare.

Common Beginner Mistakes


  • Adding several active main elements because the page has multiple sections.
  • Avoid picking tags just for their default bold, italic or spaced appearance. Use CSS for presentation.

Key Takeaways


  • Main marks the document's primary content, the part visitors came to read.
  • Main identifies the central content of the page; it should not be duplicated as separate visible main landmarks.
  • Do not put site-wide repeated navigation inside main when it is not part of the page's unique story. A clear main region makes skip links more useful.
Share this resourceSend this page to someone who may find it useful.