Open In App

HTML <main> Tag

Improve
Improve
Like Article
Like
Save
Share
Report

The HTML <main> Tag defines a document’s main content, which should be unique. It excludes content like sidebars, navigation, logos, and copyright info, ensuring unique document-specific material within.

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. 

Syntax:

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

HTML <main> Tag Examples

Example: In this example, we are using the <main> tag. It encapsulates main content, including headings and articles, conforming to HTML5 semantics.

html
<!DOCTYPE html>
<html>

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

<body>
    <h1>The &lt;Main&gt; Tag</h1>
    <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>

</body>

</html>

Output: 

MainTag

HTML <main> Tag Examples Output



Supported Browsers: The browsers supported by <main> Tag are listed below: 


Last Updated : 12 Mar, 2024
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads