Skip to content

Commit e96100f

Browse files
committed
updated headings and sections
used modified text of @annevk PR headings and sections section whatwg#3499
1 parent f86c397 commit e96100f

File tree

1 file changed

+215
-61
lines changed

1 file changed

+215
-61
lines changed

Diff for: source

+215-61
Original file line numberDiff line numberDiff line change
@@ -17475,97 +17475,251 @@ interface <dfn interface>HTMLHeadingElement</dfn> : <span>HTMLElement</span> {
1747517475

1747617476

1747717477

17478-
<h4><dfn>Headings and sections</dfn></h4>
17478+
<h4><dfn>Headings and sections</dfn></h4>
1747917479

17480-
<p>The <code>h1</code>&ndash;<code>h6</code> elements are headings.</p>
17480+
<p><span>Heading content</span> elements have a <dfn>heading level</dfn>, which is
17481+
an unsigned integer. It is determined as follows for a given <span>heading content</span> element
17482+
<var>heading</var>:</p>
1748117483

17482-
<p>The first element of <span>heading content</span> in an element of <span>sectioning
17483-
content</span> <span>represents</span> the heading for that section. Subsequent headings of equal
17484-
or higher <span>rank</span> start new (implied) sections, headings of lower <span>rank</span>
17485-
start implied subsections that are part of the previous one. In both cases, the element
17486-
<span>represents</span> the heading of the implied section.</p>
17484+
<ol>
17485+
17486+
<li>
17487+
<p>Switch on <var>heading</var>:</p>
1748717488

17488-
<p>Certain elements are said to be <dfn data-x="sectioning root">sectioning roots</dfn>, including
17489-
<code>blockquote</code> and <code>td</code> elements. These elements can have their own outlines,
17490-
but the sections and headings inside these elements do not contribute to the outlines of their
17491-
ancestors.</p>
17489+
<dl class="switch">
17490+
<dt><code>h2</code></dt>
17491+
<dd>Return 2.</dd>
1749217492

17493-
<!-- when updating this also update the category index -->
17494-
<ul class="brief category-list">
17495-
<li><code>blockquote</code></li>
17496-
<li><code>body</code></li>
17497-
<li><code>details</code></li>
17498-
<li><code>dialog</code></li>
17499-
<li><code>fieldset</code></li>
17500-
<li><code>figure</code></li>
17501-
<li><code>td</code></li>
17502-
</ul>
17493+
<dt><code>h3</code></dt>
17494+
<dd>Return 3.</dd>
17495+
17496+
<dt><code>h4</code></dt>
17497+
<dd>Return 4.</dd>
17498+
17499+
<dt><code>h5</code></dt>
17500+
<dd>Return 5.</dd>
17501+
17502+
<dt><code>h6</code></dt>
17503+
<dd>Return 6.</dd>
17504+
</dl>
17505+
</li>
17506+
17507+
</ol>
17508+
17509+
<p>A <span>heading content</span> element <span>represents</span> a <dfn data-x="concept-heading">heading</dfn>.
17510+
The lower a <span data-x="concept-heading">heading</span>'s <span>heading level</span> is, the more important
17511+
the <span data-x="concept-heading">heading</span> is.</p>
17512+
17513+
<p>The <dfn>document headings</dfn> are all <span data-x="concept-heading">headings</span> in a
17514+
document, in <span>tree order</span>.</p>
17515+
17516+
<div w-nodev>
1750317517

17504-
<!-- a document element isn't a sectioning root. This means, for instance, that you don't get an
17505-
outline if you just have a random XML file with <html:h1> elements in it. Other vocabs need to
17506-
define what their sectioning root is. -->
17518+
<p>The <span>document headings</span> must be used for generating document outlines, for
17519+
example when generating tables of contents. When creating an interactive table of contents,
17520+
entries should jump the user to the relevant <span data-x="concept-heading">heading</span>.</p>
17521+
17522+
</div>
17523+
17524+
<p>If a document has a <span data-x="concept-heading">heading</span>, at least a single <span
17525+
data-x="concept-heading">heading</span> within <span>document headings</span> must have a
17526+
<span>heading level</span> of 1.</p>
17527+
17528+
<p>Each <span data-x="concept-heading">heading</span> following another <span
17529+
data-x="concept-heading">heading</span> <var>lead</var> in <span>document headings</span> must
17530+
have a <span>heading level</span> that is less, equal, or 1 greater than <var>lead</var>'s
17531+
<span>heading level</span>.</p>
17532+
17533+
<p class="note">Authors are encouraged to avoid having a <span>sectioning content</span> element
17534+
<var>section</var> without a <span data-x="concept-heading">heading</span> descendant whose
17535+
nearest ancestor <span>sectioning content</span> element is not <var>section</var>. I.e., avoid
17536+
having a section without a heading.</p>
1750717537

1750817538
<div class="example">
17539+
<p>The following example is non-conforming:</p>
1750917540

17510-
<p>A document can contain multiple top-level headings:</p>
17541+
<pre><code class="html" data-x="">&lt;body&gt;
17542+
&lt;h4&gt;Apples&lt;/h4&gt;
17543+
&lt;p&gt;Apples are fruit.&lt;/p&gt;
17544+
&lt;section&gt;
17545+
&lt;h2&gt;Taste&lt;/h2&gt;
17546+
&lt;p&gt;They taste lovely.&lt;/p&gt;
17547+
&lt;/section&gt;
17548+
&lt;/body&gt;</code></pre>
1751117549

17512-
<pre><code class="html">&lt;!DOCTYPE HTML>
17513-
&lt;html lang=en>
17514-
&lt;title>Alphabetic Fruit&lt;/title>
17515-
&lt;h1>Apples&lt;/h1>
17516-
&lt;p>Pomaceous.&lt;/p>
17517-
&lt;h1>Bananas&lt;/h1>
17518-
&lt;p>Edible.&lt;/p>
17519-
&lt;h1>Carambola&lt;/h1>
17520-
&lt;p>Star.&lt;/p></code></pre>
17550+
<p>It could be written as follows and then it would be conforming:</p>
1752117551

17522-
<p>This would form the following simple outline consisting of three top-level sections:</p>
17552+
<pre><code class="html" data-x="">&lt;body&gt;
17553+
&lt;h1&gt;Apples&lt;/h1&gt;
17554+
&lt;p&gt;Apples are fruit.&lt;/p&gt;
17555+
&lt;section&gt;
17556+
&lt;h2&gt;Taste&lt;/h2&gt;
17557+
&lt;p&gt;They taste lovely.&lt;/p&gt;
17558+
&lt;/section&gt;
17559+
&lt;/body&gt;</code></pre>
17560+
17561+
</div>
17562+
17563+
<div class="example">
17564+
<p>The following markup fragment:</p>
17565+
17566+
<pre><code class="html" data-x="">&lt;body>
17567+
&lt;hgroup id="document-title">
17568+
&lt;h1>HTML&lt;/h1>
17569+
&lt;p>Living Standard — Last Updated 12 August 2016&lt;/p>
17570+
&lt;/hgroup>
17571+
&lt;p>Some intro to the document.&lt;/p>
17572+
&lt;h2>Table of contents&lt;/h2>
17573+
&lt;ol id=toc>...&lt;/ol>
17574+
&lt;h2>First section&lt;/h2>
17575+
&lt;p>Some intro to the first section.&lt;/p>
17576+
&lt;/body></code></pre>
17577+
17578+
<p>...results in 3 <span>document headings</span>:</p>
1752317579

1752417580
<ol class="brief">
17525-
<li> Apples
17526-
<li> Bananas
17527-
<li> Carambola
17581+
<li><p><code data-x="">&lt;hgroup id="document-title">...&lt;/hgroup></code> consisting of <code
17582+
data-x="">&lt;h1>HTML&lt;/h1></code> and <code
17583+
data-x="">&lt;p>Living Standard — Last Updated 12 August 2016&lt;/p></code>.</p></li>
17584+
17585+
<li><p><code data-x="">&lt;h2>Table of contents&lt;/h2></code>.</p></li>
17586+
17587+
<li><p><code data-x="">&lt;h2>First section&lt;/h2></code>.</p></li>
1752817588
</ol>
1752917589

17530-
<p>Effectively, the <code>body</code> element is split into three.</p>
17590+
<p>A rendered view of the <span>document headings</span> might look like:</p>
1753117591

17592+
<p><img src="/images/outline.svg" width="465" height="120" alt="Top-level section with the
17593+
heading and associated text &quot;HTML: Living Standard — Last Updated 12 August 2016&quot; and two
17594+
subsections; &quot;Table of contents&quot; and &quot;First section&quot;."></p>
1753217595
</div>
1753317596

17597+
<div class="example">
17598+
<p>First, here is a document, which is a book with very short chapters and subsections:</p>
1753417599

17535-
<h5>Exposing outlines to users</h5>
17600+
<pre><code class="html" data-x="">&lt;!DOCTYPE HTML>
17601+
&lt;html lang=en>
17602+
&lt;title>The Tax Book (all in one page)&lt;/title>
17603+
&lt;h1>The Tax Book&lt;/h1>
17604+
&lt;h2>Earning money&lt;/h2>
17605+
&lt;p>Earning money is good.&lt;/p>
17606+
&lt;h3>Getting a job&lt;/h3>
17607+
&lt;p>To earn money you typically need a job.&lt;/p>
17608+
&lt;h2>Spending money&lt;/h2>
17609+
&lt;p>Spending is what money is mainly used for.&lt;/p>
17610+
&lt;h3>Cheap things&lt;/h3>
17611+
&lt;p>Buying cheap things often not cost-effective.&lt;/p>
17612+
&lt;h3>Expensive things&lt;/h3>
17613+
&lt;p>The most expensive thing is often not the most cost-effective either.&lt;/p>
17614+
&lt;h2>Investing money&lt;/h2>
17615+
&lt;p>You can lend your money to other people.&lt;/p>
17616+
&lt;h2>Losing money&lt;/h2>
17617+
&lt;p>If you spend money or invest money, sooner or later you will lose money.
17618+
&lt;h3>Poor judgement&lt;/h3>
17619+
&lt;p>Usually if you lose money it's because you made a mistake.&lt;/p></code></pre>
17620+
17621+
<p>Its <span>document headings</span> could be presented as follows:</p>
1753617622

17537-
<p>User agents are encouraged to expose page outlines to users to aid in navigation. This is
17538-
especially true for non-visual media, e.g. screen readers.</p>
17623+
<ol class="brief">
17624+
<li> The Tax Book
17625+
<ol class="brief">
17626+
<li> Earning money
17627+
<ol class="brief">
17628+
<li> Getting a job
17629+
</ol>
17630+
<li> Spending money
17631+
<ol class="brief">
17632+
<li> Cheap things
17633+
<li> Expensive things
17634+
</ol>
17635+
<li> Investing money
17636+
<li> Losing money
17637+
<ol class="brief">
17638+
<li> Poor judgement
17639+
</ol>
17640+
</ol>
17641+
</ol>
1753917642

17540-
<p>However, to mitigate the difficulties that arise from authors misusing <span>sectioning
17541-
content</span>, user agents are also encouraged to offer a mode that navigates the page using
17542-
<span>heading content</span> alone.</p>
17643+
<p>Notice that the <code>title</code> element is not a <span
17644+
data-x="concept-heading">heading</span>.</p>
17645+
</div>
1754317646

1754417647
<div class="example">
17648+
<p>A document can contain multiple top-level headings:</p>
1754517649

17546-
<p>For instance, a user agent could map the arrow keys as follows:</p>
17650+
<pre><code class="html" data-x="">&lt;!DOCTYPE HTML>
17651+
&lt;html lang=en>
17652+
&lt;title>Alphabetic Fruit&lt;/title>
17653+
&lt;h1>Apples&lt;/h1>
17654+
&lt;p>Pomaceous.&lt;/p>
17655+
&lt;h1>Bananas&lt;/h1>
17656+
&lt;p>Edible.&lt;/p>
17657+
&lt;h1>Carambola&lt;/h1>
17658+
&lt;p>Star.&lt;/p></code></pre>
17659+
</div>
1754717660

17548-
<dl>
17549-
<dt><kbd><kbd>Shift</kbd> + <kbd>&larr; Left</kbd></kbd>
17550-
<dd>Go to previous section, including subsections of previous sections
17661+
<div class="example">
17662+
<p>The following example is non-conforming as it has no <span
17663+
data-x="concept-heading">heading</span> whose <span>heading level</span> is 1:</p>
1755117664

17552-
<dt><kbd><kbd>Shift</kbd> + <kbd>&rarr; Right</kbd></kbd>
17553-
<dd>Go to next section, including subsections of the current section
17665+
<pre><code class="html" data-x="">&lt;!DOCTYPE HTML>
17666+
&lt;html lang=en>
17667+
&lt;title>Alphabetic Fruit&lt;/title>
17668+
&lt;section>
17669+
&lt;h2>Apples&lt;/h2>
17670+
&lt;p>Pomaceous.&lt;/p>
17671+
&lt;h2>Bananas&lt;/h2>
17672+
&lt;p>Edible.&lt;/p>
17673+
&lt;h2>Carambola&lt;/h2>
17674+
&lt;p>Star.&lt;/p>
17675+
&lt;/section></code></pre>
17676+
</div>
1755417677

17555-
<dt><kbd><kbd>Shift</kbd> + <kbd>&uarr; Up</kbd></kbd>
17556-
<dd>Go to parent section of the current section
17678+
<div class="example">
17679+
<p>The following example is non-conforming as the first <span
17680+
data-x="concept-heading">heading</span>'s <span>heading level</span> is not 1:</p>
1755717681

17558-
<dt><kbd><kbd>Shift</kbd> + <kbd>&darr; Down</kbd></kbd>
17559-
<dd>Go to next section, skipping subsections of the current section
17560-
</dl>
17682+
<pre><code class="html" data-x="">&lt;!DOCTYPE HTML>
17683+
&lt;html lang=en>
17684+
&lt;title>Feathers on The Site of Encyclopedic Knowledge&lt;/title>
17685+
&lt;h2>A plea from our caretakers&lt;/h2>
17686+
&lt;p>Please, we beg of you, send help! We're stuck in the server room!&lt;/p>
17687+
&lt;h1>Feathers&lt;/h1>
17688+
&lt;p>Epidermal growths.&lt;/p></code></pre>
17689+
</div>
1756117690

17562-
<p>Plus in addition, the user agent could map the <kbd><kbd>j</kbd></kbd> and
17563-
<kbd><kbd>k</kbd></kbd> keys to navigating to the previous or next element of <span>heading
17564-
content</span>, regardless of the section's outline depth and ignoring sections with no
17565-
headings.</p>
17691+
<div class="example">
17692+
<p><code>header</code> elements do not influence the <span>document headings</span> of a
17693+
document:</p>
1756617694

17567-
</div>
17695+
<pre><code class="html" data-x="">&lt;!DOCTYPE HTML>
17696+
&lt;html lang="en">
17697+
&lt;title>We're adopting a child! &mdash; Ray's blog&lt;/title>
17698+
&lt;h1>Ray's blog&lt;/h1>
17699+
&lt;article>
17700+
&lt;header>
17701+
&lt;nav>
17702+
&lt;a href="?t=-1d">Yesterday&lt;/a>;
17703+
&lt;a href="?t=-7d">Last week&lt;/a>;
17704+
&lt;a href="?t=-1m">Last month&lt;/a>
17705+
&lt;/nav>
17706+
&lt;h2>We're adopting a child!&lt;/h2>
17707+
&lt;/header>
17708+
&lt;p>As of today, Janine and I have signed the papers to become
17709+
the proud parents of baby Diane! We've been looking forward to
17710+
this day for weeks.&lt;/p>
17711+
&lt;/article>
17712+
&lt;/html></code></pre>
1756817713

17714+
<p>The document's <span>document headings</span> could be presented as follows:</p>
17715+
17716+
<ol class="brief">
17717+
<li> Ray's blog
17718+
<ol class="brief">
17719+
<li> We're adopting a child!
17720+
</ol>
17721+
</ol>
17722+
</div>
1756917723

1757017724

1757117725
<h4>Usage summary</h4>

0 commit comments

Comments
 (0)