Main (HTML element)

From Wiki @ Karl Jones dot com
Jump to: navigation, search

In HTML5, the main element represents the main content section of the body of a document or application.

Semantic element

main is a container for holding further content.

It has semantic meaning: "contents are the main contents within this page".

The main content section consists of content that is directly related to or expands upon the central topic of a document or central functionality of an application.

Note: the main element is not sectioning content and has no effect on the document outline.

The main content section of a document includes content that is unique to that document and excludes content that is repeated across a set of documents such as site navigation links, copyright information, site logos and banners and search forms (unless the document or applications main function is that of a search form).

Authors MUST NOT include more than one main element in a document.

Authors MUST NOT include the main element as a child of an article, aside, footer, header or nav element.

Example

<main>
  <h1>Introduction to web design</h1>
  <p>This page introduces web design.</p>

  <article>
    <h1>Text</h1>
    <p>Web design begins with text.</p>
  </article>

  <article>
    <h1>HTML</h1>
    <p>HTML is a markup language. It provides structure.</p>
  </article>

  <article>
    <h1>Cascading Style Sheets (CSS)</h1>
    <p>CSS is a style language. It provides look and feel.</p>
  </article>
</main>

See also

External links