summaryrefslogtreecommitdiff
path: root/devdocs/html/element%2Fmain.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/html/element%2Fmain.html')
-rw-r--r--devdocs/html/element%2Fmain.html125
1 files changed, 125 insertions, 0 deletions
diff --git a/devdocs/html/element%2Fmain.html b/devdocs/html/element%2Fmain.html
new file mode 100644
index 00000000..b2f6a0cb
--- /dev/null
+++ b/devdocs/html/element%2Fmain.html
@@ -0,0 +1,125 @@
+<header><h1>&lt;main&gt;</h1></header><div class="section-content"><p>The <code>&lt;main&gt;</code> <a href="../index">HTML</a> element represents the dominant content of the <a href="body"><code>&lt;body&gt;</code></a> of a document. The main content area consists of content that is directly related to or expands upon the central topic of a document, or the central functionality of an application.</p></div>
+<h2 id="try_it">Try it</h2>
+<div class="section-content">
+<iframe class="interactive is-tabbed-shorter-height" height="200" src="https://interactive-examples.mdn.mozilla.net/pages/tabbed/main.html" title="MDN Web Docs Interactive Example" loading="lazy"></iframe> <p>A document mustn't have more than one <code>&lt;main&gt;</code> element that doesn't have the <a href="../global_attributes#hidden"><code>hidden</code></a> attribute specified.</p> <figure class="table-container"><div class="_table"><table class="properties"> <tbody> <tr> <th scope="row"><a href="../content_categories">Content categories</a></th> <td>
+<a href="../content_categories#flow_content">Flow content</a>, palpable content.</td> </tr> <tr> <th scope="row">Permitted content</th> <td>
+<a href="../content_categories#flow_content">Flow content</a>.</td> </tr> <tr> <th scope="row">Tag omission</th> <td>None; both the starting and ending tags are mandatory.</td> </tr> <tr> <th scope="row">Permitted parents</th> <td> Where <a href="../content_categories#flow_content">flow content</a> is expected, but only if it is a <a href="https://html.spec.whatwg.org/multipage/grouping-content.html#hierarchically-correct-main-element" target="_blank">hierarchically correct <code>main</code> element</a>. </td> </tr> <tr> <th scope="row">Implicit ARIA role</th> <td><code><a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/main_role">main</a></code></td> </tr> <tr> <th scope="row">Permitted ARIA roles</th> <td>No <code>role</code> permitted</td> </tr> <tr> <th scope="row">DOM interface</th> <td><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement"><code>HTMLElement</code></a></td> </tr> </tbody> </table></div></figure>
+</div>
+<h2 id="attributes">Attributes</h2>
+<div class="section-content"><p>This element only includes the <a href="../global_attributes">global attributes</a>.</p></div>
+<h2 id="usage_notes">Usage notes</h2>
+<div class="section-content">
+<p>The content of a <code>&lt;main&gt;</code> element should be unique to the document. Content that is repeated across a set of documents or document sections such as sidebars, navigation links, copyright information, site logos, and search forms shouldn't be included unless the search form is the main function of the page.</p> <p><code>&lt;main&gt;</code> doesn't contribute to the document's outline; that is, unlike elements such as <a href="body"><code>&lt;body&gt;</code></a>, headings such as <a href="heading_elements">h2</a>, and such, <code>&lt;main&gt;</code> doesn't affect the <a href="https://developer.mozilla.org/en-US/docs/Glossary/DOM">DOM's</a> concept of the structure of the page. It's strictly informative.</p>
+</div>
+<h2 id="examples">Examples</h2>
+<div class="section-content"><div class="code-example">
+<p class="example-header"><span class="language-name">html</span></p>
+<pre data-signature="tyfb3BYxWBtdvVUJ+iaJ7d3DOTT4AcsjzuhhiNZbuFA=" data-language="html"><span class="token comment">&lt;!-- other content --&gt;</span>
+
+<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>main</span><span class="token punctuation">&gt;</span></span>
+ <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h1</span><span class="token punctuation">&gt;</span></span>Apples<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h1</span><span class="token punctuation">&gt;</span></span>
+ <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">&gt;</span></span>The apple is the pomaceous fruit of the apple tree.<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">&gt;</span></span>
+
+ <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>article</span><span class="token punctuation">&gt;</span></span>
+ <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h2</span><span class="token punctuation">&gt;</span></span>Red Delicious<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h2</span><span class="token punctuation">&gt;</span></span>
+ <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">&gt;</span></span>
+ These bright red apples are the most common found in many supermarkets.
+ <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">&gt;</span></span>
+ <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">&gt;</span></span>…<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">&gt;</span></span>
+ <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">&gt;</span></span>…<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">&gt;</span></span>
+ <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>article</span><span class="token punctuation">&gt;</span></span>
+
+ <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>article</span><span class="token punctuation">&gt;</span></span>
+ <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h2</span><span class="token punctuation">&gt;</span></span>Granny Smith<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h2</span><span class="token punctuation">&gt;</span></span>
+ <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">&gt;</span></span>These juicy, green apples make a great filling for apple pies.<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">&gt;</span></span>
+ <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">&gt;</span></span>…<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">&gt;</span></span>
+ <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">&gt;</span></span>…<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">&gt;</span></span>
+ <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>article</span><span class="token punctuation">&gt;</span></span>
+<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>main</span><span class="token punctuation">&gt;</span></span>
+
+<span class="token comment">&lt;!-- other content --&gt;</span>
+</pre>
+</div></div>
+<h3 id="result">Result</h3>
+<div class="section-content"><div class="code-example" id="sect1">
+
+<iframe class="sample-code-frame" title="Examples sample" id="frame_examples" src="https://live.mdnplay.dev/en-US/docs/Web/HTML/Element/main/runner.html?id=examples" loading="lazy"></iframe>
+</div></div>
+<h2 id="accessibility_concerns">Accessibility concerns</h2>
+
+<h3 id="landmark">Landmark</h3>
+<div class="section-content"><p>The <code>&lt;main&gt;</code> element behaves like a <a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/main_role"><code>main</code> landmark</a> role. <a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques#landmark_roles">Landmarks</a> can be used by assistive technology to quickly identify and navigate to large sections of the document. Prefer using the <code>&lt;main&gt;</code> element over declaring <code>role="main"</code>, unless there are <a href="#browser_compatibility">legacy browser support concerns</a>.</p></div>
+<h3 id="skip_navigation">Skip navigation</h3>
+<div class="section-content">
+<p>Skip navigation, also known as "skipnav", is a technique that allows an assistive technology user to quickly bypass large sections of repeated content (main navigation, info banners, etc.). This lets the user access the main content of the page faster.</p> <p>Adding an <a href="../global_attributes#id"><code>id</code></a> attribute to the <code>&lt;main&gt;</code> element lets it be a target of a skip navigation link.</p> <div class="code-example">
+<p class="example-header"><span class="language-name">html</span></p>
+<pre data-signature="aBaSk9dQ7yDgTfk+fBabUFcjDX4FCxV/mO+DRQSOZNg=" data-language="html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>body</span><span class="token punctuation">&gt;</span></span>
+ <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>a</span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>#main-content<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span>Skip to main content<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>a</span><span class="token punctuation">&gt;</span></span>
+
+ <span class="token comment">&lt;!-- navigation and header content --&gt;</span>
+
+ <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>main</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>main-content<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span>
+ <span class="token comment">&lt;!-- main page content --&gt;</span>
+ <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>main</span><span class="token punctuation">&gt;</span></span>
+<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>body</span><span class="token punctuation">&gt;</span></span>
+</pre>
+</div> <ul> <li><a href="https://webaim.org/techniques/skipnav/" target="_blank">WebAIM: "Skip Navigation" Links</a></li> </ul>
+</div>
+<h3 id="reader_mode">Reader mode</h3>
+<div class="section-content">
+<p>Browser reader mode functionality looks for the presence of the <code>&lt;main&gt;</code> element, as well as <a href="heading_elements">heading</a> and <a href="../element#content_sectioning">content sectioning elements</a> when converting content into a specialized reader view.</p> <ul> <li><a href="https://medium.com/@mandy.michael/building-websites-for-safari-reader-mode-and-other-reading-apps-1562913c86c9" target="_blank">Building websites for Safari Reader Mode and other reading apps.</a></li> </ul>
+</div>
+<h2 id="specifications">Specifications</h2>
+<div class="_table"><table class="standard-table">
+<thead><tr><th scope="col">Specification</th></tr></thead>
+<tbody><tr><td><a href="https://html.spec.whatwg.org/multipage/grouping-content.html#the-main-element">HTML Standard <br><small># the-main-element</small></a></td></tr></tbody>
+</table></div>
+<h2 id="browser_compatibility">Browser compatibility</h2>
+<div class="_table"><table>
+<thead>
+<tr id="bct-browser-type">
+<th></th>
+<th colspan="6">Desktop</th>
+<th colspan="6">Mobile</th>
+</tr>
+<tr id="bct-browsers">
+<th></th>
+<th>Chrome</th>
+<th>Edge</th>
+<th>Firefox</th>
+<th>Internet Explorer</th>
+<th>Opera</th>
+<th>Safari</th>
+<th>WebView Android</th>
+<th>Chrome Android</th>
+<th>Firefox for Android</th>
+<th>Opera Android</th>
+<th>Safari on IOS</th>
+<th>Samsung Internet</th>
+</tr>
+</thead>
+<tbody><tr>
+<th><code>main</code></th>
+<td class="bc-supports-yes">26</td>
+<td class="bc-supports-yes">12</td>
+<td class="bc-supports-yes">21</td>
+<td class="bc-supports-no">No</td>
+<td class="bc-supports-yes">16</td>
+<td class="bc-supports-yes">7</td>
+<td class="bc-supports-yes">4.4</td>
+<td class="bc-supports-yes">26</td>
+<td class="bc-supports-yes">21</td>
+<td class="bc-supports-yes">14</td>
+<td class="bc-supports-yes">7</td>
+<td class="bc-supports-yes">1.5</td>
+</tr></tbody>
+</table></div>
+<h2 id="see_also">See also</h2>
+<div class="section-content"><ul> <li>Basic structural elements: <a href="html"><code>&lt;html&gt;</code></a>, <a href="head"><code>&lt;head&gt;</code></a>, <a href="body"><code>&lt;body&gt;</code></a>
+</li> <li>Section-related elements: <a href="article"><code>&lt;article&gt;</code></a>, <a href="aside"><code>&lt;aside&gt;</code></a>, <a href="footer"><code>&lt;footer&gt;</code></a>, <a href="header"><code>&lt;header&gt;</code></a>, or <a href="nav"><code>&lt;nav&gt;</code></a>
+</li> <li><a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/main_role">ARIA: Main role</a></li> </ul></div><div class="_attribution">
+ <p class="_attribution-p">
+ &copy; 2005&ndash;2023 MDN contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>
+ <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/main" class="_attribution-link">https://developer.mozilla.org/en-US/docs/Web/HTML/Element/main</a>
+ </p>
+</div>