Skip to the page
html reference · layout

HTML <main> tag

closing tag
required
void element
no
lives inside
<body>
typically holds
the content unique to this page

Where it goes

Inside <body>. Open it after <header> and <nav> if you have them, and close it before <footer>. It never wraps <head>, and it never wraps the header, nav or footer.

Example

<body>
  <header>...</header>
  <nav>...</nav>
  <main>
    <h1>Page title</h1>
    <p>The actual content.</p>
  </main>
  <footer>...</footer>
</body>

Open this example in the editor →

Common mistakes

  • Putting <header> or <footer> inside <main>. They sit next to it, not inside it.
  • Using more than one <main> on a page. There is only ever one.
  • Opening <main> before <body> starts. It belongs inside <body> like all visible content.

Related

Updated 24 October 2026. Practice it in the html route, or read more on MDN.