-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Restrict the main element to be used once per document #3354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
2c570b9
38465fa
8f1b75f
701e6bc
433ec9c
be4c49d
cac0c21
8460af5
783612c
0bc0404
5050f0f
8200648
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10698,7 +10698,6 @@ console.assert(image.height === 200);</pre> | |
| <li><code>kbd</code></li> | ||
| <li><code>label</code></li> | ||
| <li><code>link</code> (if it is <span>allowed in the body</span>)</li> | ||
| <li><code>main</code></li> | ||
| <li><code>map</code></li> | ||
| <li><code>mark</code></li> | ||
| <li><span>MathML <code>math</code></span></li> | ||
|
|
@@ -11007,7 +11006,6 @@ https://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E% | |
| <li><code>ins</code></li> | ||
| <li><code>kbd</code></li> | ||
| <li><code>label</code></li> | ||
| <li><code>main</code></li> | ||
| <li><code>map</code></li> | ||
| <li><code>mark</code></li> | ||
| <li><span>MathML <code>math</code></span></li> | ||
|
|
@@ -15142,7 +15140,8 @@ interface <dfn>HTMLStyleElement</dfn> : <span>HTMLElement</span> { | |
| <dt><span data-x="concept-element-contexts">Contexts in which this element can be used</span>:</dt> | ||
| <dd>As the second element in an <code>html</code> element.</dd> | ||
| <dt><span data-x="concept-element-content-model">Content model</span>:</dt> | ||
| <dd><span>Flow content</span>.</dd> | ||
| <dd>Zero or one <code>main</code> element optionally intermixed with <span>flow | ||
| content</span>.</dd> | ||
| <dt><span data-x="concept-element-attributes">Content attributes</span>:</dt> | ||
| <dd><span>Global attributes</span></dd> | ||
| <dd><code data-x="handler-window-onafterprint">onafterprint</code></dd> | ||
|
|
@@ -15172,7 +15171,7 @@ interface <dfn>HTMLBodyElement</dfn> : <span>HTMLElement</span> {}; | |
| <dd w-nohtml>Uses <code>HTMLBodyElement</code>.</dd> | ||
| </dl> | ||
|
|
||
| <p>The <code>body</code> element <span>represents</span> the main content of the document.</p> | ||
| <p>The <code>body</code> element <span>represents</span> the contents of the document.</p> | ||
|
|
||
| <p>In conforming documents, there is only one <code>body</code> element. The <code | ||
| data-x="dom-document-body">document.body</code> IDL attribute provides scripts with easy access to | ||
|
|
@@ -15552,7 +15551,7 @@ interface <dfn>HTMLBodyElement</dfn> : <span>HTMLElement</span> {}; | |
| <dt><span data-x="concept-element-contexts">Contexts in which this element can be used</span>:</dt> | ||
| <dd>Where <span>flow content</span> is expected.</dd> | ||
| <dt><span data-x="concept-element-content-model">Content model</span>:</dt> | ||
| <dd><span>Flow content</span>, but with no <code>main</code> element descendants.</dd> | ||
| <dd><span>Flow content</span>.</dd> | ||
| <dt><span data-x="concept-element-attributes">Content attributes</span>:</dt> | ||
| <dd><span>Global attributes</span></dd> | ||
| <dt><span data-x="concept-element-dom">DOM interface</span>:</dt> | ||
|
|
@@ -15729,7 +15728,7 @@ interface <dfn>HTMLBodyElement</dfn> : <span>HTMLElement</span> {}; | |
| <dt><span data-x="concept-element-contexts">Contexts in which this element can be used</span>:</dt> | ||
| <dd>Where <span>flow content</span> is expected.</dd> | ||
| <dt><span data-x="concept-element-content-model">Content model</span>:</dt> | ||
| <dd><span>Flow content</span>, but with no <code>main</code> element descendants.</dd> | ||
| <dd><span>Flow content</span>.</dd> | ||
| <dt><span data-x="concept-element-attributes">Content attributes</span>:</dt> | ||
| <dd><span>Global attributes</span></dd> | ||
| <dt><span data-x="concept-element-dom">DOM interface</span>:</dt> | ||
|
|
@@ -16118,7 +16117,8 @@ Space is not the only void</pre> | |
| <dt><span data-x="concept-element-contexts">Contexts in which this element can be used</span>:</dt> | ||
| <dd>Where <span>flow content</span> is expected.</dd> | ||
| <dt><span data-x="concept-element-content-model">Content model</span>:</dt> | ||
| <dd><span>Flow content</span>, but with no <code>header</code>, <code>footer</code>, or <code>main</code> element descendants.</dd> | ||
| <dd><span>Flow content</span>, but with no <code>header</code> or <code>footer</code> element | ||
| descendants.</dd> | ||
| <dt><span data-x="concept-element-attributes">Content attributes</span>:</dt> | ||
| <dd><span>Global attributes</span></dd> | ||
| <dt><span data-x="concept-element-dom">DOM interface</span>:</dt> | ||
|
||
|
|
@@ -16204,7 +16204,8 @@ Space is not the only void</pre> | |
| <dt><span data-x="concept-element-contexts">Contexts in which this element can be used</span>:</dt> | ||
| <dd>Where <span>flow content</span> is expected.</dd> | ||
| <dt><span data-x="concept-element-content-model">Content model</span>:</dt> | ||
| <dd><span>Flow content</span>, but with no <code>header</code>, <code>footer</code>, or <code>main</code> element descendants.</dd> | ||
| <dd><span>Flow content</span>, but with no <code>header</code> or <code>footer</code> element | ||
| descendants.</dd> | ||
| <dt><span data-x="concept-element-attributes">Content attributes</span>:</dt> | ||
| <dd><span>Global attributes</span></dd> | ||
| <dt><span data-x="concept-element-dom">DOM interface</span>:</dt> | ||
|
|
@@ -16348,9 +16349,8 @@ Space is not the only void</pre> | |
| <dt><span data-x="concept-element-contexts">Contexts in which this element can be used</span>:</dt> | ||
| <dd>Where <span>flow content</span> is expected.</dd> | ||
| <dt><span data-x="concept-element-content-model">Content model</span>:</dt> | ||
| <dd><span>Flow content</span>, but with no <span>heading | ||
| content</span> descendants, no <span>sectioning content</span> | ||
| descendants, and no <code>header</code>, <code>footer</code>, or | ||
| <dd><span>Flow content</span>, but with no <span>heading content</span> descendants, no | ||
| <span>sectioning content</span> descendants, and no <code>header</code>, <code>footer</code>, or | ||
| <code>address</code> element descendants.</dd> | ||
| <dt><span data-x="concept-element-attributes">Content attributes</span>:</dt> | ||
| <dd><span>Global attributes</span></dd> | ||
|
|
@@ -18877,7 +18877,8 @@ first matching case):</p> | |
| <dd>Before <code>dd</code> or <code>dt</code> elements inside <code>dl</code> elements.</dd> | ||
| <dd>Before <code>dd</code> or <code>dt</code> elements inside <code>div</code> elements that are children of a <code>dl</code> element.</dd> | ||
| <dt><span data-x="concept-element-content-model">Content model</span>:</dt> | ||
| <dd><span>Flow content</span>, but with no <code>header</code>, <code>footer</code>, <span>sectioning content</span>, or <span>heading content</span> descendants.</dd> | ||
| <dd><span>Flow content</span>, but with no <code>header</code>, <code>footer</code>, | ||
| <span>sectioning content</span>, or <span>heading content</span> descendants.</dd> | ||
| <dt><span data-x="concept-element-attributes">Content attributes</span>:</dt> | ||
| <dd><span>Global attributes</span></dd> | ||
| <dt><span data-x="concept-element-dom">DOM interface</span>:</dt> | ||
|
|
@@ -18962,9 +18963,9 @@ first matching case):</p> | |
| <dt><span data-x="concept-element-contexts">Contexts in which this element can be used</span>:</dt> | ||
| <dd>Where <span>flow content</span> is expected.</dd> | ||
| <dt><span data-x="concept-element-content-model">Content model</span>:</dt> | ||
| <dd>Either: One <code>figcaption</code> element followed by <span>flow content</span>.</dd> | ||
| <dd>Or: <span>Flow content</span> followed by one <code>figcaption</code> element.</dd> | ||
| <dd>Or: <span>Flow content</span>.</dd> | ||
| <dd>Either: one <code>figcaption</code> element followed by <span>flow content</span>.</dd> | ||
| <dd>Or: <span>flow content</span> followed by one <code>figcaption</code> element.</dd> | ||
| <dd>Or: <span>flow content</span>.</dd> | ||
| <dt><span data-x="concept-element-attributes">Content attributes</span>:</dt> | ||
| <dd><span>Global attributes</span></dd> | ||
| <dt><span data-x="concept-element-dom">DOM interface</span>:</dt> | ||
|
|
@@ -19188,24 +19189,21 @@ included with Exhibit B. | |
| <dd><span>Flow content</span>.</dd> | ||
| <dd><span>Palpable content</span>.</dd> | ||
| <dt><span data-x="concept-element-contexts">Contexts in which this element can be used</span>:</dt> | ||
| <dd>Where <span>flow content</span> is expected.</dd> | ||
| <dd>As a child of a <code>body</code> or <code>div</code> element.</dd> | ||
| <dt><span data-x="concept-element-content-model">Content model</span>:</dt> | ||
| <dd><span>Flow content</span>.</dd> | ||
| <dd><span>Flow content</span>, but with no <code>main</code> element descendants.</dd> | ||
| <dt><span data-x="concept-element-attributes">Content attributes</span>:</dt> | ||
| <dd><span>Global attributes</span></dd> | ||
| <dt><span data-x="concept-element-dom">DOM interface</span>:</dt> | ||
| <dd>Uses <code>HTMLElement</code>.</dd> | ||
| </dl> | ||
|
|
||
| <p>The <code>main</code> element can be used as a container for the dominant contents of the | ||
| document. It <span>represents</span> its children.</p> | ||
|
|
||
| <p class="note">The <code>main</code> element is distinct from the <code>section</code> and | ||
| <code>article</code> elements in that the <code>main</code> element does not contribute to the | ||
| document <span>outline</span>.</p> | ||
| <p>The <code>main</code> element <span>represents</span> the dominant contents of the | ||
| document.</p> | ||
|
|
||
| <p class="note">While there is no restriction as to the number of <code>main</code> elements in a | ||
| document, web developers are encouraged to stick to a single element.</p> | ||
| <p>A document must not have more than one <code>main</code> element, unless all but one of the | ||
| <code>main</code> elements in the document have the <code data-x="attr-hidden">hidden</code> | ||
| attribute specified.</p> | ||
|
|
||
| <div class="example"> | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is great, simplified a lot of the other bits. Thanks! |
||
|
|
@@ -19247,6 +19245,35 @@ included with Exhibit B. | |
| </footer> | ||
| </html></pre> | ||
|
|
||
| <p>In the following example, multiple <code>main</code> elements are used and script is used to | ||
| make navigation work without a server roundtrip and to set the <code | ||
| data-x="attr-hidden">hidden</code> attribute on those that are not current: | ||
|
|
||
| <pre><!doctype html> | ||
| <html lang=en-CA> | ||
| <meta charset=utf-8> | ||
| <title> … </title> | ||
| <link rel=stylesheet href=spa.css> | ||
| <script src=spa.js async></script> | ||
| <nav> | ||
| <a href=/>Home</a> | ||
| <a href=/about>About</a> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good example! |
||
| <a href=/contact>Contact</a> | ||
| </nav> | ||
| <main> | ||
| <h1>Home</h1> | ||
| … | ||
| </main> | ||
| <main hidden> | ||
| <h1>About</h1> | ||
| … | ||
| </main> | ||
| <main hidden> | ||
| <h1>Contact</h1> | ||
| … | ||
| </main> | ||
| <footer>Made with ❤️ by <a href=https://example.com/>Example 👻</a>.</footer></pre> | ||
|
|
||
| </div> | ||
|
|
||
|
|
||
|
|
@@ -19262,7 +19289,8 @@ included with Exhibit B. | |
| <dd>As a child of a <code>dl</code> element.</dd> | ||
| <dt><span data-x="concept-element-content-model">Content model</span>:</dt> | ||
| <dd>If the element is a child of a <code>dl</code> element: one or more <code>dt</code> elements followed by one or more <code>dd</code> elements, optionally intermixed with <span>script-supporting elements</span>.</dd> | ||
| <dd>If the element is not a child of a <code>dl</code> element: <span>Flow content</span>.</dd> | ||
| <dd>If the element is not a child of a <code>dl</code> element: zero or one <code>main</code> | ||
| element optionally intermixed with <span>flow content</span>.</dd> | ||
| <dt><span data-x="concept-element-attributes">Content attributes</span>:</dt> | ||
| <dd><span>Global attributes</span></dd> | ||
| <dt><span data-x="concept-element-dom">DOM interface</span>:</dt> | ||
|
|
@@ -115902,7 +115930,8 @@ interface <dfn>External</dfn> { | |
| <td>Document body</td> | ||
| <td><span data-x="Sectioning root">sectioning root</span></td> | ||
| <td><code>html</code></td> | ||
| <td><span data-x="Flow content">flow</span></td> | ||
| <td><span data-x="Flow content">flow</span>; | ||
| <code>main</code>*</td> | ||
| <td><span data-x="global attributes">globals</span>; | ||
| <code data-x="handler-window-onafterprint">onafterprint</code>; | ||
| <code data-x="handler-window-onbeforeprint">onbeforeprint</code>; | ||
|
|
@@ -116130,7 +116159,8 @@ interface <dfn>External</dfn> { | |
| <span data-x="Palpable content">palpable</span></td> | ||
| <td><span data-x="Flow content">flow</span>; | ||
| <code>dl</code></td> | ||
| <td><span data-x="Flow content">flow</span></td> | ||
| <td><span data-x="Flow content">flow</span>; | ||
| <code>main</code>*</td> | ||
| <td><span data-x="global attributes">globals</span></td> | ||
| <td><code>HTMLDivElement</code></td> | ||
| </tr> | ||
|
|
@@ -116530,10 +116560,10 @@ interface <dfn>External</dfn> { | |
|
|
||
| <tr> | ||
| <th><code>main</code></th> | ||
| <td>Container for the dominant contents of another element</td> | ||
| <td><span data-x="Flow content">flow</span>; | ||
| <span data-x="Palpable content">palpable</span></td> | ||
| <td><span data-x="Flow content">flow</span></td> | ||
| <td>Container for the dominant contents of the document</td> | ||
| <td>none</td> | ||
| <td><code>body</code>; | ||
| <code>div</code></td> | ||
| <td><span data-x="Flow content">flow</span></td> | ||
| <td><span data-x="global attributes">globals</span></td> | ||
| <td><code>HTMLElement</code></td> | ||
|
|
@@ -117416,7 +117446,6 @@ interface <dfn>External</dfn> { | |
| <code>ins</code>; | ||
| <code>kbd</code>; | ||
| <code>label</code>; | ||
| <code>main</code>; | ||
| <code>map</code>; | ||
| <code>mark</code>; | ||
| <span>MathML <code>math</code></span>; | ||
|
|
@@ -117696,7 +117725,6 @@ interface <dfn>External</dfn> { | |
| <code>ins</code>; | ||
| <code>kbd</code>; | ||
| <code>label</code>; | ||
| <code>main</code>; | ||
| <code>map</code>; | ||
| <code>mark</code>; | ||
| <span>MathML <code>math</code></span>; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be zero or more to allow for
<main hidden>, right?