start learning
Image 1
3202

HTML Main tag

The HTML <main> tag represents the main content of a web page. It's used to encapsulate the primary content that is directly related to the purpose of the page. The <main> tag is intended to contain the central focus of the page's content and should be unique within the document – meaning there should only be one <main> per page.

Here's an example of how the <header> tag can be used in an HTML document:


<!DOCTYPE html>
<html>
<head>
    <title>Sample Page</title>
</head>
<body>
      <header>
        <!-- Header content here including h1 heading title -->
    </header>
    <main>
       <article>
            <p>Post Title</p>
            <p>This is the content of the blog post...</p>
        </article>
        <article>
            <h2>Another Post Title</h2>
            <p>This is another blog post...</p>
        </article>
    </main>
    <footer>
        <!-- Footer content here -->
    </footer>
</body>
</html>

In this example, the <main> tag encloses the main content area of the page, which consists of two blog posts. The content within the <main> tag is considered to be the central focus of the page's content.

Using the <main> tag helps provide semantic structure to your HTML document and makes it easier for both users and search engines to identify and distinguish the primary content area. It's especially useful for accessibility purposes, as assistive technologies can use the <main> tag to understand and navigate the core content of the page.

×