html
  1. html-main-tag

HTML <main> Tag

  • The <main> tag is a semantic tag in HTML which represents the main content of the document.
  • It is typically used for the central content of a web page, and should not contain any content that is repeated across multiple web pages, such as headers or navigation menus.

Syntax

The <main> tag can be used as follows:

<main>
  <!-- Main content goes here -->
</main>

Example

<!DOCTYPE html>
<html>
<head>
    <title>Example of Main Tag</title>
</head>
<body>
    <main>
        <h1>Welcome to my website</h1>
        <p>Here is some important information about my website.</p>
    </main>
</body>
</html>
Try Playground

The output of the above example code will be a web page with a heading "Welcome to my website" and some important information about it.

Explanation

The <main> element is a tag that is used to define the main content of a web page. It should be used only once per page and it should contain the primary content or central topic of the web page. It is also recommended to include a heading within the <main> tag to give context to the content.

Use

The <main> tag is used to identify the main content area of a web page and must not include any content such as navigation bars, headers, or footers that will be displayed across multiple pages. It should be used once per page and it helps search engines to identify the significant content of the page.

Important Points

  • The <main> element is a semantic tag used for representing the main content of the web page.
  • It should only be used once per page and can contain other HTML elements.
  • The <main> tag should not include content such as headers and footers, which are common across multiple pages.
  • It helps search engines, screen readers, and browsers to identify the significant content of the page.

Summary

The <main> tag is used to define the main content area of a web page. It is a semantic tag that should only be used once per page and not include content like navigation bars, headers, and footers. The use of the main tag in HTML code helps search engines to understand the important content of the page and enhances the accessibility of websites.

Published on: