Skip to content
Merged
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
71d2930
implement headingoffset & headingreset attributes
keithamus Feb 28, 2025
451d3f7
s/comptued/computed
keithamus Mar 1, 2025
0d6e538
s/child elements/descendants/
keithamus Mar 1, 2025
3123eb0
s/authors prevent/authors to prevent/
keithamus Mar 1, 2025
359a581
add note on aria-level, example
keithamus Mar 1, 2025
94e938b
add IDL reflections
keithamus Mar 22, 2025
7cd1052
s/child/ancestor
keithamus Jun 27, 2025
3925155
s/&/&
keithamus Jun 27, 2025
e24647c
clarify aria-level only has precedence in a11y mapping
keithamus Jun 27, 2025
09be4bf
clarify the example is illustrative
keithamus Jun 27, 2025
cc8c891
rework the inner loop
keithamus Jun 27, 2025
0dc88bd
drop redundant "element" word
keithamus Jun 27, 2025
1fc5897
s/zero/0
keithamus Jun 27, 2025
c4f794e
title case
keithamus Jun 27, 2025
aa37dba
add commas
keithamus Jun 27, 2025
0131b0e
use "increment by"
keithamus Jun 27, 2025
010ad2b
split parsing step into a nextOffset variable
keithamus Jun 27, 2025
1af79a6
s/be/to
keithamus Jun 27, 2025
0ad92dc
switch from "attribute is present" to "has an attribute"
keithamus Jun 27, 2025
841e50d
remove newlines
keithamus Jun 27, 2025
500ebb2
oxford comma
keithamus Jun 27, 2025
c7282ae
fix wonky html
keithamus Jun 27, 2025
feac8de
Merge remote-tracking branch 'upstream/main' into implement-headingof…
keithamus Aug 14, 2025
520a6f9
s/this point/the element with the attribute/
keithamus Aug 14, 2025
9b11911
add reflect IDL attribute to headingoffset/headingreset
keithamus Aug 14, 2025
00aaad4
remove redundant prose about reflection
keithamus Aug 14, 2025
c8787c4
use more succinct method definition
keithamus Aug 14, 2025
01cb751
drop max from algorithms
keithamus Aug 14, 2025
8b4a23a
drop comment
keithamus Aug 14, 2025
b977e3a
s/ancestor/inclusiveAncestor
keithamus Aug 14, 2025
56a59e2
drop note around aria-level precedence
keithamus Aug 14, 2025
ee960d2
canonicalise dfn for headingReset
keithamus Aug 14, 2025
28b18bf
remove redundant var
keithamus Aug 14, 2025
fe07ece
remove early return
keithamus Aug 14, 2025
6f238f0
ensure only html elements are checked
keithamus Aug 14, 2025
0a45caa
use ReflectRange=0,9
keithamus Aug 14, 2025
a69944a
s/zero/0
keithamus Aug 14, 2025
fbfdd36
s/set <var>level</var> to 9/return 9
keithamus Aug 14, 2025
82d212a
add then
keithamus Aug 14, 2025
fb63403
reorder global attributes
keithamus Aug 15, 2025
b7c8070
Fix end tag
keithamus Aug 15, 2025
72260b3
accidentally a greather
keithamus Aug 15, 2025
f7a4db5
use :heading pseudo class for default UA sheet
keithamus Aug 15, 2025
5da2989
add :heading(7..9)
keithamus Aug 15, 2025
f58bc44
fix range to (0, 8)
keithamus Aug 18, 2025
46d15b9
Merge remote-tracking branch 'upstream/main' into implement-headingof…
keithamus Sep 11, 2025
e32ceff
use comma separated integers for heading(6+) in UA sheet
keithamus Sep 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 125 additions & 8 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -4352,6 +4352,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li><dfn data-x-href="https://w3c.github.io/aria/#aria-describedby"><code data-x="attr-aria-describedby">aria-describedby</code></dfn></li>
<li><dfn data-x-href="https://w3c.github.io/aria/#aria-disabled"><code data-x="attr-aria-disabled">aria-disabled</code></dfn></li>
<li><dfn data-x-href="https://w3c.github.io/aria/#aria-label"><code data-x="attr-aria-label">aria-label</code></dfn></li>
<li><dfn data-x-href="https://w3c.github.io/aria/#aria-level"><code data-x="attr-aria-level">aria-level</code></dfn></li>
</ul>

<p>Finally, the following terms are defined in <cite>ARIA</cite>: <ref>ARIA</ref></p>
Expand Down Expand Up @@ -12095,6 +12096,9 @@ interface <dfn interface>HTMLElement</dfn> : <span>Element</span> {
undefined <span data-x="dom-hidePopover">hidePopover</span>();
boolean <span data-x="dom-togglePopover">togglePopover</span>(optional (<span>TogglePopoverOptions</span> or boolean) options = {});
[<span>CEReactions</span>] attribute DOMString? <span data-x="dom-popover">popover</span>;

[<span>CEReactions</span>, <span data-x="xattr-Reflect">Reflect</span>, <span data-x="xattr-ReflectRange">ReflectRange=(0, 8)</span>] attribute unsigned long <dfn attribute for="HTMLElement" data-x="dom-headingOffset">headingOffset</dfn>;
[<span>CEReactions</span>, <span data-x="xattr-Reflect">Reflect</span>] attribute boolean <dfn attribute for="HTMLElement" data-x="dom-headingReset">headingReset</dfn>;
};

dictionary <dfn dictionary>ShowPopoverOptions</dfn> {
Expand Down Expand Up @@ -13432,6 +13436,8 @@ https://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%
<li><code data-x="attr-dir">dir</code></li>
<li><code data-x="attr-draggable">draggable</code></li>
<li><code data-x="attr-enterkeyhint">enterkeyhint</code></li>
<li><code data-x="attr-headingoffset">headingoffset</code></li>
<li><code data-x="attr-headingreset">headingreset</code></li>
<li><code data-x="attr-hidden">hidden</code></li>
<li><code data-x="attr-inert">inert</code></li>
<li><code data-x="attr-inputmode">inputmode</code></li>
Expand Down Expand Up @@ -19556,8 +19562,9 @@ interface <dfn interface>HTMLHeadingElement</dfn> : <span>HTMLElement</span> {

<h4><span id="headings-and-outlines"></span><span id="outlines"></span>Headings and outlines</h4>

<p><code>h1</code>&ndash;<code>h6</code> elements have a <dfn>heading level</dfn>, which is given
by the number in the element's name.</p>
<p><code>h1</code>&ndash;<code>h6</code> elements have a <dfn>heading level</dfn>, which is
given by <span data-x="get an element's computed heading level">getting the element's computed
heading level</span>.</p>

<p>These elements <span data-x="represents">represent</span> <dfn
data-x="concept-heading">headings</dfn>. The lower a <span
Expand Down Expand Up @@ -19605,6 +19612,110 @@ interface <dfn interface>HTMLHeadingElement</dfn> : <span>HTMLElement</span> {

</div>

<h5>Heading levels &amp; offsets</h5>

<p>The <dfn element-attr for="global"><code data-x="attr-headingoffset">headingoffset</code></dfn>
content attribute allows authors to offset heading levels for descendants.</p>

<p>The <dfn element-attr for="global"><code data-x="attr-headingreset">headingreset</code></dfn>
content attribute allows authors to prevent a heading offset computation from traversing beyond
the element with the attribute.</p>

<p>To <dfn>get an element's computed heading level</dfn>, given an element
<var>element</var>:</p>

<ol>
<li><p>Let <var>level</var> be 0.</p></li>

<li><p>If <var>element</var>'s local name is <code data-x="h1">h1</code>, then set
<var>level</var> to 1.</p></li>

<li><p>If <var>element</var>'s local name is <code data-x="h2">h2</code>, then set
<var>level</var> to 2.</p></li>

<li><p>If <var>element</var>'s local name is <code data-x="h3">h3</code>, then set
<var>level</var> to 3.</p></li>

<li><p>If <var>element</var>'s local name is <code data-x="h4">h4</code>, then set
<var>level</var> to 4.</p></li>

<li><p>If <var>element</var>'s local name is <code data-x="h5">h5</code>, then set
<var>level</var> to 5.</p></li>

<li><p>If <var>element</var>'s local name is <code data-x="h6">h6</code>, then set
<var>level</var> to 6.</p></li>

<li><p><span>Assert</span>: <var>level</var> is not 0.</p></li>

<li><p>Increment <var>level</var> by the result of <span
data-x="get an element's computed heading offset">getting an element's computed heading
offset</span> given <var>element</var>.</p></li>

<li><p>If <var>level</var> is greater than 9, then return 9.</p></li>

<li><p>Return <var>level</var>.</p></li>
</ol>

<p>To <dfn>get an element's computed heading offset</dfn>, given an element <var>element</var>,
perform the following steps. They return a non-negative integer.</p>

<ol>
<li><p>Let <var>offset</var> be 0.</p></li>

<li><p>Let <var>inclusiveAncestor</var> be <var>element</var>.</p></li>

<li>
<p>While <var>inclusiveAncestor</var> is not null:</p>

<ol>
<li><p>Let <var>nextOffset</var> be 0.</p></li>

<li>
<p>If <var>inclusiveAncestor</var> is an <span data-x="HTML elements">HTML element</span> and
has a <code data-x="attr-headingoffset">headingoffset</code> attribute, then parse its value
using the <span>rules for parsing non-negative integers</span>.</p>

<p>If the result of parsing the value is not an error, then set <var>nextOffset</var> to that
value.</p>
</li>

<li><p>Increment <var>offset</var> by <var>nextOffset</var></p></li>

<li><p>If <var>inclusiveAncestor</var> is an <span data-x="HTML elements">HTML element</span>
and has a <code data-x="attr-headingreset">headingreset</code> attribute, then return
<var>offset</var>.</p></li>

<li><p>Set <var>inclusiveAncestor</var> to the parent node of <var>inclusiveAncestor</var>
within the <span>flat tree</span>.</p></li>
</ol>
</li>

<li><p>Return <var>offset</var>.</p></li>
</ol>

<div class="example">
<p>This example shows a combination of <code data-x="attr-headingoffset">headingoffset</code>,
<code data-x="attr-headingreset">headingreset</code>, and <code
data-x="attr-aria-level">aria-level</code> attributes with comments demonstrating the respective
heading levels. This example illustrates the various combinations and is not a best practice
example.</p>

<pre><code class="html">&lt;body>
&lt;main>
&lt;h1>This is a heading level 1&lt;/h1>
&lt;article headingoffset="1">
&lt;h1>This is a heading level 2&lt;/h1>
&lt;section headingoffset="1">
&lt;h1>This is a heading level 3&lt;/h1>
&lt;dialog headingreset>
&lt;h1>This is a heading level 1&lt;/h1>
&lt;/dialog>
&lt;/section>
&lt;/article>
&lt;h1 aria-level="2">This is a heading level 2&lt;/h1>
&lt;/main>
&lt;/body></code></pre>
</div>

<h5>Sample outlines</h5>

Expand Down Expand Up @@ -140450,12 +140561,18 @@ article, aside, :heading, hgroup, nav, section {
display: block;<!-- see also unicode-bidi: isolate rules-->
}

h1 { margin-block: 0.67em; font-size: 2.00em; font-weight: bold; }
h2 { margin-block: 0.83em; font-size: 1.50em; font-weight: bold; }
h3 { margin-block: 1.00em; font-size: 1.17em; font-weight: bold; }
h4 { margin-block: 1.33em; font-size: 1.00em; font-weight: bold; }
h5 { margin-block: 1.67em; font-size: 0.83em; font-weight: bold; }
h6 { margin-block: 2.33em; font-size: 0.67em; font-weight: bold; }</code></pre>
:heading { font-weight: bold; }

:heading(1) { margin-block: 0.67em; font-size: 2.00em; }
:heading(2) { margin-block: 0.83em; font-size: 1.50em; }
:heading(3) { margin-block: 1.00em; font-size: 1.17em; }
:heading(4) { margin-block: 1.33em; font-size: 1.00em; }
:heading(5) { margin-block: 1.67em; font-size: 0.83em; }
:heading(6, 7, 8, 9) {
font-size: 0.67em;
margin-block: 2.33em;
}
</code></pre>



Expand Down