Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / HTML

headingoffset — offsetting heading levels

The global HTML attribute `headingoffset` increases computed heading levels. It accepts an integer from 0 to 8; nested offsets add together, while `headingreset` establishes a boundary for the offset calculation.

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

Syntax

headingoffset="N" (N: integer, 0–8)

headingoffset is a global HTML attribute for offsetting heading levels within an element's content. Its value must be a valid non-negative integer from 0 through 8, inclusive. It is not a boolean attribute: writing it without a value does not mean an offset of one.

Calculation starts with the level implied by the heading's name: h1 means 1, and h6 means 6. Offsets from the heading itself and its ancestors are then added. Nested values accumulate; the final level is capped at 9. A missing attribute or a value that fails parsing contributes 0. When crossing a shadow root boundary, calculation continues at its host.

The boolean attribute headingreset stops traversal to further ancestors, but only after including any headingoffset on that same element. Merely setting headingoffset="0" does not stop accumulation. This mechanism concerns semantic level—it does not rename the element; do not treat it as a font-size setting.

In the example, the expected levels are 1, 2, 3, 1, in order. The output field describes the standard's algorithmic result, not text printed by the page. Before deployment, check your target browsers and assistive technologies; inclusion in the standard is not confirmation of implementation support.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Heading offsets</title>
<body>
  <h1>Guide</h1>
  <section headingoffset="1">
    <h1>Installation</h1>
    <section headingoffset="1">
      <h1>Requirements</h1>
      <div headingreset>
        <h1>Independent heading</h1>
      </div>
    </section>
  </section>
</body>
</html>

Result

Guide: 1
Installation: 2
Requirements: 3
Independent heading: 1

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources