Anyone who builds reusable components has run into the heading problem. A card component has a title. Is it an <h2>? An <h3>? It depends on where the card ends up. On the home page it sits under an <h1>. In a sidebar it might sit under an <h3>. Most teams either pass a level prop through every component or give up and pick the heading tag by its font size. That second option leaves screen-reader users with a broken outline.

HTML now has a native fix: the headingoffset and headingreset global attributes. Firefox 162, due on 8 December 2026, turns headingoffset on by default, according to the Firefox 162 release notes for developers. This post explains how the attributes work, how to use them in components, and how to adopt them safely while browser support is still limited.

What headingoffset does

Every heading has a computed heading level. This is the level assistive technologies such as screen readers announce. Normally it’s just the number in the tag: <h2> is level 2.

headingoffset adds to that number for every heading inside the element it’s set on. From the MDN reference:

  • The value is an integer from 0 to 8. Anything that can’t be parsed counts as 0.
  • The browser starts at the heading, walks up through its ancestors (crossing shadow DOM boundaries), and adds up every headingoffset it finds.
  • The walk stops at the first element with headingreset, after adding that element’s own offset.
  • The computed level never goes above 9. Levels 7, 8 and 9 can only come from headingoffset or aria-level.

What it does not change matters just as much:

  • The element is still an <h1>, so CSS selectors like h1 still match and default styles stay the same.
  • The ARIA role is still heading.
  • An explicit aria-level on the heading wins over the computed level.

A simple example

Here the same component markup appears twice. The second copy is one level deeper:

<h1>Insect guide</h1>

<article>
  <h1>Beetles</h1>
  <p>A beetle has a hardened forewing.</p>
</article>

<section headingoffset="1">
  <h1>Appendix</h1>
  <article>
    <h1>Beetles, revisited</h1>
    <p>The same component, one level deeper.</p>
  </article>
</section>

In a supporting browser, the computed levels are: Insect guide 1, Beetles 1, Appendix 2, Beetles, revisited 2.

Offsets stack. This <h2> is announced as level 5:

<article headingoffset="1">
  <section headingoffset="2">
    <h2>Level 5</h2>
  </section>
</article>

Writing components that adapt to their context

The practical win is that a component can always use the same heading tag, and the page decides how deep it sits. Here’s a product card written once with <h2> for its title and <h3> inside:

<template id="product-card">
  <article class="card">
    <h2 class="card__title"><slot name="title"></slot></h2>
    <slot></slot>
    <h3 class="card__sub">Specifications</h3>
    <slot name="specs"></slot>
  </article>
</template>

Placed directly under the page <h1>, its title is level 2. Placed inside a section whose own heading is an <h2>, you shift it by one:

<h1>Laptops</h1>

<section>
  <h2>Featured</h2>
  <div headingoffset="1">
    <product-card>…</product-card>   <!-- title: level 3, specs: level 4 -->
  </div>
</section>

Because the offset walk crosses shadow DOM boundaries, this works for web components too. Set the offset on the host or any ancestor.

In React, Vue or Angular, the attribute replaces a level prop threaded through every component. Wrap the outlet once:

function Sidebar({ children }) {
  // Everything inside is one level deeper than the sidebar heading (h2)
  return (
    <aside>
      <h2>Related</h2>
      <div headingoffset="2">{children}</div>
    </aside>
  );
}

Here children use <h1> for their titles, so they become level 3 under the sidebar’s level-2 heading. Check that your framework passes unknown attributes through to the DOM. React and Vue usually do for lowercase attribute names, but your type definitions may complain until they add it.

Resetting for dialogs and embedded content

Content that isn’t part of the page’s outline, such as a modal dialog, should start fresh. Use headingreset:

<section headingoffset="2">
  <h1>Level 3</h1>

  <dialog headingreset>
    <h1>Level 1</h1>
  </dialog>
</section>

The dialog’s <h1> is announced as level 1, no matter how deeply the dialog sits in the DOM.

Styling: keep visual size separate from level

Because headingoffset doesn’t change the tag, h1 { font-size: 2.5rem } would make every component title huge. The cleanest approach is to style headings by class or context, not by tag:

/* base reset: headings look the same until a context styles them */
:where(h1, h2, h3, h4, h5, h6) {
  font-size: 1.125rem;
  line-height: 1.25;
  margin-block: 0 0.5em;
}

.page-title     { font-size: clamp(2rem, 5vw, 3rem); }
.card__title    { font-size: 1.25rem; }
.card__sub      { font-size: 1rem; text-transform: uppercase; letter-spacing: .04em; }
aside .card__title { font-size: 1.05rem; }

:where() keeps the base rules at zero specificity, so component classes always override them. This separation is the real point of the feature. Tags describe the structure and classes describe the look.

Browser support and progressive enhancement

Support is still limited. MDN marks headingoffset as experimental and not Baseline. According to MDN’s browser compatibility data:

  • Firefox 162: supported (release scheduled for 8 December 2026).
  • Safari: listed for version 27.3.
  • Chrome and Edge: available from version 151 only behind the Experimental Web Platform features flag.

In browsers without support, headings simply keep the level of their tag. So write markup that still makes sense without the offset:

  1. Choose tags that are correct in the most common placement of each component.
  2. Add headingoffset only where a component is nested deeper than that.
  3. Where the level must be exact in every browser today, set aria-level on the heading. It takes precedence anyway.
<!-- exact everywhere today, still clean once headingoffset is supported -->
<h2 class="card__title" aria-level="3">Battery life</h2>

Testing the outline

Don’t guess. Check the computed levels:

  • Open your browser’s Accessibility inspector and select a heading. It shows the level that will be announced.
  • Use a screen reader’s headings list (for example, the rotor in VoiceOver or the elements list in NVDA) and check the outline reads logically.
  • Make sure no level is skipped, for example jumping from 2 straight to 4.

Takeaway

headingoffset lets components keep one heading markup and lets the page set the depth, while headingreset gives dialogs a clean start. Support is limited (Firefox 162, Safari listed at 27.3, Chrome behind a flag), so pick sensible default tags, use aria-level where exact levels matter today, and style headings by class rather than by tag. Read the full MDN reference before you roll it out.