English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag Reference

HTML: <main> tag

The HTML <main> tag is an HTML5An element used to define the main content of an HTML document, and there should be only one <main> element in the document. This tag is also commonly referred to as the <main> element.

Online example

The syntax for the <main> tag in HTML is:

<body>
<main role="main">
  <h1>oldtoolbag.com</h1>
  <p>Your trusted resource for learning new technologies</p>
  <article>
    <h2>HTML</h2>
    <p>Learn HTML (HyperText Markup Language) through our step-by-step tutorial and reference materials.</p>
  </article>
  <article>
    <h2>CSS</h2>
    <p>Learn CSS (Cascading Style Sheets) through our step-by-step tutorial and reference materials.</p>
  </article>
</main>
</body>

Browser compatibility

IEFirefoxOperaChromeSafari

All major browsers support the <main> tag.

Try online examples

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>HTML5 main tag usage (Basic Tutorial Website oldtoolbag.com)</title>
</head>
<body>
<main role="main">
  <h1>oldtoolbag.com</h1>
  <p>Your trusted resource for learning new technologies.</p>
  <article>
    <h2>HTML</h2>
    <p>Learn HTML (HyperText Markup Language) through our step-by-step tutorial and reference materials.</p>
  </article>
  <article>
    <h2>CSS</h2>
    <p>Learn CSS (Cascading Style Sheets) through our step-by-step tutorial and reference materials.</p>
  </article>
</main>
</body>
</html>
Test to see ‹/›

tag definition and usage instructions

The HTML <main> element is found within the <body> tag5elements.

The <main> tag should not be used for repeated content, such as navigation, website logo, social media links, copyright information, and sidebars.

It is recommended to use the ARIA role 'main' on the <main> element so that screen readers in old browsers can access it, for example: <main role="main">

for IE versions earlier than 9for IE browsers, please use HTML5shiv, which is a JavaScript solution that can provide support for new HTML5elements provide support, such as: <header>, <main>, <article>, <section>, <aside>, <nav>, <footer>.

In the document, the content of the <main> element should be unique. Any identical or duplicate content that exists in any series of documents, such as sidebars, navigation bar links, copyright information, website logos, search boxes (unless the search box is the main function of the document), should not be included within it.