HTML headingreset Attribute
The HTML headingreset global attribute prevents headingoffset values on ancestor elements from affecting headings inside the element. It creates a boundary for computed heading levels while still allowing a headingoffset specified on the same element to apply.
Syntax
The headingreset attribute is a Boolean global attribute and does not require a value.
<div headingreset>
<h1>Independent Heading</h1>
</div>
When the browser calculates the heading's computed level, it stops collecting headingoffset values when it reaches the element with headingreset.
Global Attribute
The headingreset attribute is a global attribute, so it can be specified on HTML elements. Its purpose is to establish a boundary when the browser calculates the computed levels of headings within that part of the document.
<section headingoffset="2">
<div headingreset>
<h1>Heading</h1>
</div>
</section>
The headingoffset="2" on the outer section does not affect the heading because the inner element has headingreset.
Boolean Attribute
The headingreset attribute is a Boolean attribute. Its presence enables the behavior regardless of any value assigned to it.
<div headingreset>...</div>
Writing headingreset="false" does not turn the attribute off. Because the attribute is present, heading offset calculation still stops at that element. To disable the behavior, omit the attribute.
Resetting Heading Offsets
Normally, the browser determines a heading's computed level by adding applicable headingoffset values found on the heading and its ancestors. The headingreset attribute prevents the calculation from continuing beyond the element on which it appears.
<section headingoffset="2">
<h1>Computed Level 3</h1>
<dialog open headingreset>
<h1>Computed Level 1</h1>
</dialog>
</section>
The first <h1> receives the section's offset and has a computed level of 3. The heading inside the dialog remains at computed level 1 because headingreset prevents the section's offset from reaching it.
Using headingreset with headingoffset
An element can have both headingreset and headingoffset. In this situation, the element's own offset is included, but offsets from ancestors above the reset element are ignored.
<div headingoffset="3">
<div headingreset headingoffset="1">
<h1>Computed Level 2</h1>
</div>
</div>
The outer offset of 3 does not apply. The inner element's offset of 1 does apply, giving the <h1> a computed heading level of 2.
Common Uses
The headingreset attribute is useful for content whose heading structure should be independent of the surrounding document, such as dialogs, popovers, reusable components, or markup inserted into different locations.
By establishing a reset boundary, the same component can avoid inheriting heading offsets from more distant ancestors while still defining its own offset when necessary.
Accessibility
Heading levels communicate document structure to users of assistive technologies. The headingreset attribute can prevent unrelated ancestor offsets from changing the computed levels of headings in independent content.
Because browser support is currently limited, the underlying <h1> through <h6> elements should still provide a meaningful structure when headingreset is not supported.
Common Mistakes
Do not use headingreset="false" when you want ancestor offsets to continue applying. The attribute is Boolean, so its presence activates the reset behavior.
Do not assume that headingreset removes a headingoffset specified on the same element. That offset is included before the heading calculation stops.
Do not use headingreset to change the visual appearance of headings. It affects computed heading levels, not their CSS styling.
Because support is not yet available in every core browser, do not rely on headingreset as the only way to provide a meaningful heading structure.
Browser Support
Baseline: Limited availability indicates that a feature is not yet available in all core browsers. Use these features with caution because they may only work in select browsers, so additional compatibility checks may be needed before general use.
The headingreset global attribute has limited availability and should be tested before it is relied on for document heading structure.
Checking Browser Support
For current browser compatibility information, visit Can I Use? . Search for the HTML element or attribute you want to check. You can also narrow your search by entering an element name and attribute name separated by a colon. Search results can include related HTML features, element attributes, input types, APIs, and other technologies, so select the result that most closely matches the feature you are checking.
Try the headingreset Attribute
The example places two <h1> elements inside an element with headingoffset="2". The first receives the offset, while the second is inside an element with headingreset and does not receive the ancestor offset.
Summary
The HTML headingreset global attribute is a Boolean attribute that stops ancestor headingoffset values from contributing to the computed levels of headings within an element. An offset specified on the reset element itself still applies, making headingreset useful for dialogs, popovers, reusable components, and other content that needs an independent heading structure.
