HTML <main> Tag

Last Updated : 29 May, 2026

The HTML <main> tag represents the primary content of a web page. It contains the central information unique to the document, excluding repeated elements such as navigation menus, sidebars, headers, and footers.

  • Identifies the main topic or purpose of the web page.
  • Improves page structure and semantic meaning.
  • Helps assistive technologies locate the primary content easily.
  • There should be only one <main> element per document.
  • Should not be placed inside <header>, <footer>, <nav>, or <aside> elements.

Syntax:

<main>
    // contents of main Element 
</main> 

Note: The document must not contain more than one <main> element. The <main> element should not be a child element of an <article>, <aside>, <footer>, <header>, or <nav> element. 

HTML <main> Tag Examples

Example: Using the <main> tag, it encapsulates main content, including headings and articles, conforming to HTML5 semantics.

html
<!--Driver Code Starts-->
<!DOCTYPE html>
<html>

<head>
    <title>The &lt;Main&gt; Tag</title>
</head>

<body>
    <h1>The &lt;Main&gt; Tag</h1>
<!--Driver Code Ends-->

    <main>
        <h1>Programming Languages</h1>
        <p>c programming, C++
            Programming, Java Programming</p>

        <article>
            <h1>C Programming</h1>
            <p>C is a Procedural language</p>
        </article>

        <article>
            <h1>C++ Programming</h1>
            <p>C++ programming is a
                Object oriented Programming.</p>
        </article>

        <article>
            <h1>Java Programming</h1>
            <p>Java is a pure Object
                oriented Programming.</p>
        </article>
    </main>

<!--Driver Code Starts-->

</body>

</html>
<!--Driver Code Ends-->
Comment