Main HTML

HTML <main> Tag

The main content of the <body> tag can be specified using the HTML <main> tag. Thus, the primary content of a page can be accurately described using the HTML <main> tag. It is placed within the HTML <body> tag. It was introduced in HTML5. It is recommended to use only one <main> tag within a document, and this tag should not be used as a child of the HTML <article>, <aside>, <header>, <footer>, and <nav> elements.

Example:

<!DOCTYPE html>
<html>
<body>
 
<main>
  <h1>Health</h1>
  <p>Health includes both the physical and mental well-being.</p>
 
  <article>
    <h1>Diet</h1>
    <p>Eat balanced-diet to stay healthy.</p>
  </article>
 
  <article>
    <h1>Exercise</h1>
    <p>Exercise daily to stay fit and healthy.</p>
  </article>
 
  <article>
    <h1>Sleep</h1>
    <p>Take proper rest and sound sleep to stay healthy.</p>
  </article>
</main>
 
</body>
</html>

Explanation:

In the above example, we are using the HTML <main> tag to specify the primary content of the document.

Global Attributes:

The HTML Global attributes are supported by the HTML <main> tag.

Event Attributes:

The HTML Event attributes are supported by the HTML <main> tag.

Supporting Browsers:

Chrome, IE, Firefox, Opera, and Safari.