HTML <main> Tag

The HTML <main> tag is a semantic tag used to define the main content of the document. The main content contains the primary information or functionality that the page is meant to provide to the user. For example,

<body>
    <header>Programiz</header>
    <main>
        <p>Learn HTML with us.</p>
    </main>
</body>

Browser Output

Sample article with the main tag

Generally, the <main> tag should not contain auxiliary parts of the article like nav links, sidebar, copyright note, logo, etc. The content of the main title should be unique to the HTML document.


Example: HTML <main>

<main>
    <h1>HTML Tutorial</h1>
    <p>Welcome to our HTML tutorial! In this tutorial, you will learn the basics of HTML and how to use it to create
        your own web pages.</p>

    <h2>Chapter 1: Introduction to HTML</h2>
    <article>
        <h3>What is HTML?</h3>
        <p>HTML (Hypertext Markup Language) is a markup language used to structure and format content on the web. It
            uses a system of tags to define the different elements of a web page, such as headings, paragraphs, and
            links.</p>
    </article>
    <h2>Chapter 2: Getting Started with HTML</h2>
    <article>
        <h3>Creating an HTML Document</h3>
        <p>To create an HTML document, you will need a text editor and a web browser. You can use a simple text editor
            like Notepad on Windows, or TextEdit on Mac. Once you have a text editor, you can create a new HTML document
            by saving a file with the ".html" extension.</p>
    </article>
</main>

Browser Output

Sample article with the main tag