main element | main object

The main element represents the main content of the body of a document or application. Specifying main content is used to indicate content that is unique to the document, and excludes repeated content over other documents such as navigation links.

DOM Information

Inheritance Hierarchy

 Node
  Element
   HTMLElement
     main

Members

The main object does not define any members.

Standards information

Remarks

Because the main element is not a sectioning content element, main has no effect on the document outline.

No more than one main element may be included in a document.

A main element must not be a descendant of an article, aside, footer, header, or nav element.

The main element is not suitable for use to identify main content areas of sub sections within a document or application.

Examples

The following example shows the main element being used to specify content within a document that is unique.


<html>

<head>
  <title>My Website</title>
</head>

<body>
  <header>
    <h1>My Website</h1>
    <nav>
      <a href="home.html">Home</a> | <a href="projects.html">Projects</a> | <a>About me</a>
    </nav>
  </header>

  <main>
    <h2>About me</h2>
    <nav>
      <ul>
        <li><a href="#education">Education</a></li>
        <li><a href="#goal">Goals</a></li>
    </nav>

    <h3 id="education">Education</h3>
    <p><strong>University of Washington</strong>
      </br>Degree: B.S. Computer Science
      </br>GPA: 3.9/4.0</p>

    <h3 id="goal">Goal</h3>
    <p>My goal is to develop software for a company that is extremely passionate about robotics.</p>
  </main>

  <footer>Copyright 2015</footer>

</body>

</html>

See also

Node

 

 

Show: