<main> Tag — HTML Technical Interview Questions & Answers

The dominant, unique content of the document body.

<main> Tag

  • The dominant, unique content of the document body.
  • <main> is the <main> HTML element. HTML uses this tag so the browser (and screen readers) know what the piece is, not only how it looks.
  • Board: <main>…</main> Put it in body. Check it in the browser. Attributes go on the opening tag.
  • Trap: wrong nesting or missing a required attribute. CSS can still style it — don’t pick a tag only because of default italics.
  • Interview: name the tag, one attribute if it has a famous one (href, src, alt, for, type), one mistake.

Technical Interview Tip: <main>: the <main> HTML element. Example: <main>…</main>

Code Examples for <main> Tag

<main> Tag — working example

<header>
  <nav aria-label="Primary"><a href="/">Home</a></nav>
</header>
<main>
  <article>
    <h1>Interview tip</h1>
    <p>Prefer semantic tags over empty divs when meaning exists.</p>
  </article>
  <aside>
    <p>Related: practice aloud for 30 seconds.</p>
  </aside>
</main>
<footer>© GoCareerGo</footer>

<main> Tag — semantic tags describe meaning — better SEO/a11y than only div/span layout shells.

How to Explain <main> Tag to an Interviewer

What is the <main> tag?

the <main> HTML element <main>…</main>

One common mistake?

wrong nesting or missing a required attribute