Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / HTML

HTML concept: document-outline

A document outline is the ordered heading structure used for navigation and tables of contents; it is not an automatically generated section tree exposed through a dedicated DOM API.

Version: WHATWG HTML Living Standard; index snapshot date recorded separately

Syntax

headings in tree order + computed heading levels

The standard defines the outline as every h1, h2, h3, h4, h5, and h6 element in tree order, interpreted by computed heading level. If a document has headings, at least one should have level 1, and a following heading must not jump downward by more than one level.

The section, article, nav, and aside elements give content sectioning meaning but do not by themselves change a heading rank. The newer headingoffset and headingreset attributes participate in level computation; check their support in target browsers and accessibility tools.

The title element is not an outline heading, and a header container does not itself affect the outline. There is no standard document.outline property; a script producing a table of contents must collect headings, preserve order, and create links. CSS font size does not change semantic level.

The example collects h1, h2, h3, h4, h5, and h6 in tree order, shows three headings that are direct children of sections, and observes the absence of document.outline. The result demonstrates author-provided structure, not a particular screen reader’s presentation.

Examples

<!doctype html>
<meta charset="utf-8">
<main>
  <h1>Guide</h1>
  <section><h2>Start</h2></section>
  <section><h2>Finish</h2><h3>Details</h3></section>
</main>
<output id="result"></output>
<script>
const headings = Array.from(document.querySelectorAll("h1,h2,h3,h4,h5,h6"), heading => `${heading.localName}:${heading.textContent}`);
const sectionHeadings = Array.from(document.querySelectorAll("section > h1,section > h2,section > h3,section > h4,section > h5,section > h6"), heading => heading.localName);
result.textContent = `outline=${headings.join(">")}; sections=${sectionHeadings.join(",")}; api=${"outline" in document}`;
</script>

Result

outline=h1:Guide>h2:Start>h2:Finish>h3:Details; sections=h2,h2,h3; api=false

The executed example verifies heading order and the absence of an outline object; it does not prove how every assistive technology presents that structure.

Sources