How many <main> main tag can be used in html document / page

how many main tags can I add to my html page. Is there any limitation for adding more than one main tag (like one per page)?

is the correct way to use the main tag

<body>
  <header></header>
  <aside></aside>
  <main>
    <section></section>
    <main>is this correct!!!</main>
  </main>
  <footer></footer>

      

+3


source to share


3 answers


The element main

represents the main content of the body of a document or application. The main content area consists of content that is directly related to or extends to the central theme of the document or the central functionality of the application.

Authors should not include more than one main element in a document. ( source )



The authors do not include the main element as a child element article

, aside

, footer

, header

or nav

.

+3


source


just one time

here's a great article on HTML5 DOCTOR .

It should contain the main content of the document or annex. Its most important goal is to "bind the main role of ARIAs to an element in HTML".



It cannot be used as a descendant of an element <article>, <aside>, <footer>, <header>, or <nav>

.

here's an example of typical usage.

<body>
<header role="banner"></header>
<main id="content" class="group" role="main">

<!-- main content -->

</main>
<footer role="contentinfo"></footer>
</body>

      

+2


source


It can not be more than once and should not be a descendant of any of these elements <article>

, <aside>

, <footer>

, <header>

or <nav>

.

The purpose of the tag <main>

is to indicate the main content of the document. Hence, it must be a container main

, stripped of its semantics, and must be used once in an HTML document.

Browser support: The tag <main>

has good support in all modern browsers, except for large IE

You can read more details with an example here (w3schools).

+1


source







All Articles