The <main> Element
Technical Summary
The main element represents the document's dominant contents. The HTML Standard does not allow more than one main element without a hidden attribute in one document.
Its allowed ancestors are limited. For accessibility, it maps to the WAI-ARIA main role, a landmark. Normative requirements, browser behavior, and WPT coverage are recorded separately.
Definition / Categories
| Item | Specification summary |
|---|---|
| Meaning | The dominant contents of the document |
| Categories | Flow content and palpable content; not sectioning content |
| Context | Where flow content is expected, only if the ancestor elements are allowed |
| Content model | Flow content |
| Tag omission | Neither the start nor end tag may be omitted |
| Content attributes | Global attributes; no main-specific attributes |
| DOM interface | HTMLElement |
“Dominant contents” does not mean the largest visual region or simply the first content in the document. It means content directly related to the document's central topic or function.
Document count and the hidden attribute
The HTML Standard's conformance rule is that a document must not contain more than one main element without a hidden attribute. This rule checks the attribute, not whether CSS currently displays the element.
<main>This document's content</main>
<main hidden>Content for another state</main>
An element hidden with display: none still lacks the hidden attribute, so it still counts for this conformance rule. Conversely, CSS can change how an element with hidden looks while the attribute remains in the DOM. Check HTML conformance separately from rendered visibility.
An iframe loads a separate Document. Each Document can have its own main.
Placement and ancestors
The HTML Standard limits the ancestors of a main element to:
html,body, anddiv- a
formwithout an accessible name - autonomous custom elements
Therefore, a main inside article, aside, footer, header, nav, or another main is non-conforming. In ordinary pages, placing it directly inside body or beneath only div elements makes the rule easy to check.
This hierarchy rule is an HTML conformance requirement. How a browser exposes a non-conforming element in its Accessibility Tree is a separate implementation observation.
Content model and DOM
The content model is flow content, so main can contain headings, paragraphs, lists, and articles. The main element is not sectioning content and does not create heading levels. Use h1–h6 to express the page title and heading hierarchy.
The HTML Standard defines no main-specific content attributes. The element accepts global attributes such as id, class, and lang. Its DOM interface is HTMLElement.
const main = document.querySelector('main');
console.log(main instanceof HTMLElement); // true
console.log(main.localName); // "main"
console.log(getComputedStyle(main).display); // observe the browser's initial style
The HTML Standard defines a block-level default rendering for main. Site CSS can override it, so implementation reports should include the Computed Style of the page being measured.
Accessibility / HTML-AAM
The HTML-AAM 1.0 Working Draft (2026-10-21) maps the implicit role of main to the WAI-ARIA main role. WAI-ARIA defines main as a landmark. This gives browsers and assistive technologies a structural cue for reaching the document's central content.
The main role allows an author-provided accessible name, but WAI-ARIA does not require one. A single main landmark usually does not need an additional aria-label. Consider a label when multiple document contexts or main regions need to be distinguished.
The HTML placement rule and the role that a browser publishes in its Accessibility Tree are different facts. An observation in one browser does not establish results for every operating-system accessibility API or assistive technology.
Fact / Evidence
Normative requirements, accessibility mappings, browser observations, and the scope of WPT execution are kept distinct.
| Type | Fact / claim | Conditions / scope | Status | Source |
|---|---|---|---|---|
| SPEC | main represents the document's dominant contents and is flow content. | HTML Living Standard 4.4.14: meaning, categories, context, and content model. | Specification checked | HTML Standard: The main element |
| SPEC | A document must not contain more than one main without hidden; each main must have only permitted ancestors. | HTML Living Standard cardinality and hierarchically-correct-main rules. CSS visibility is a separate condition. | Specification checked | HTML Standard: cardinality and hierarchy |
| AAM | HTML-AAM maps main to the WAI-ARIA main role. The role is a landmark and does not require an accessible name. | HTML-AAM 1.0 WD 2026-10-21 / WAI-ARIA 1.2. Normative text and browser observations are separate. | Mapping checked | HTML-AAM: main · WAI-ARIA: main role |
Evidence
- HTML Living Standard, 4.4.14 The main element — meaning, categories, context, content model, hierarchy, and document cardinality.
- HTML Accessibility API Mappings 1.0 Working Draft, 2026-10-21 — implicit role and platform API mappings.
- WAI-ARIA 1.2, main role — landmark meaning, supported naming, and accessible-name requirement.
- Selected WPT: reflection-grouping.html — the grouping-element reflection suite includes
main; it does not cover all main placement or landmark rules. - WPT HTML DOM tests — source directory for the selected test.
Implementation Evidence
Browser observations and WPT were run in Chrome 156 on 2026-10-25. The fixture checked a normal main, the hidden attribute, a CSS-hidden main, and a separate Document inside an iframe. We also checked display width, theme, and role queries on all four pages. All 5,904 selected WPT checks passed, but this suite does not directly test main placement rules or landmarks.
Dedicated fixture: main-v1 compares a main with a correct ancestor hierarchy, the hidden attribute, CSS-hidden main, and a separate Document inside an iframe. It deliberately has two mains without hidden in the same Document, so the fixture is for observation rather than a conforming page example. The fixture is docs/atlas/main-v1-fixture.html; the run record is docs/atlas/main-evidence-2026-10-25.md.
| Type | Scope checked | Conditions to record | Status |
|---|---|---|---|
| IMPL | DOM and Computed Style observations of document count, the hidden attribute, hierarchy, default display, and an iframe's separate Document; responsive and shared features on all four pages |
2026-10-25 / Chrome UA 156.0.0.0 / Windows NT 10.0. In docs/atlas/main-v1-fixture.html, the ordinary main had display:block and was an HTMLElement; the hidden and CSS-hidden cases had display:none; there were 2 mains without hidden and 1 main in the separate Document. Checked all four Yugien/Atlas ja/en pages at the default viewport 1280x720 / DPR 1.25 and responsive viewport 390x844 / DPR 1.0. Each page had one main, a shared search link, two language alternate links, and no horizontal overflow. |
Partial observation (one Chrome environment) |
| WPT | Grouping-element reflection WPT; this is not a dedicated test of main placement, document count, or landmark mapping |
2026-10-25 / Chrome UA 156.0.0.0 / Windows NT 10.0 / wpt.live. Ran reflection-grouping.html. Harness status OK; 5,904 of 5,904 tests passed. The WPT grouping-elements list includes main, but this result does not test HTML Standard placement or cardinality rules, or the HTML-AAM role mapping. The commit SHA served by wpt.live was not available, so wptRevision is null. Other WPT files and browsers were not run.The test version used was not recorded. The linked test may change, so this result cannot be repeated with certainty against the same version. |
Partial run (served revision unknown) |
| AAM | Chromium main recognition observed with a Playwright role query and the browser DOM snapshot |
2026-10-25 / Chrome UA 156.0.0.0 / fixture docs/atlas/main-v1-fixture.html. Playwright getByRole('main') found 1 visible main, 1 main with the accessible name 主コンテンツ, and 1 main in the iframe's separate Document. The hidden and CSS display:none cases were omitted from the default query. Each of the four pages also returned 1. This is a Chromium role-query observation; Windows UI Automation, IAccessible2, and screen-reader output were not measured. Codex's DOM snapshot shows main as a container, so it is kept separate from a platform accessibility API tree. |
Partial observation (Chromium role query) |
A passing selected WPT file does not establish that every main placement rule, browser, operating-system accessibility API, or assistive technology was tested.
Coverage / Open Issues
- Specification checkedMeaning, categories, context, content model, cardinality, ancestors, and DOM interface
- Specification checkedHTML-AAM main-role mapping and WAI-ARIA landmark / accessible-name requirements
- Partly observedChrome 156, standard and narrow viewports, light and dark themes, main role query on all four pages, and 5,904 selected WPT passes. See Implementation Evidence for scope.
- OpenOther browsers, Windows UI Automation, IAccessible2, and assistive-technology speech
The served WPT commit was not available. Results from the selected WPT file are not presented as verification of every HTML Standard placement rule.
Related surfaces
For a beginner-friendly explanation, see the Yugien page about the main element. A standalone post inside the primary content is covered by the article element; document boundaries for embedded content are covered by the iframe element; links are covered by the a element.