diff options
Diffstat (limited to 'devdocs/html/element%2Fdiv.html')
| -rw-r--r-- | devdocs/html/element%2Fdiv.html | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/devdocs/html/element%2Fdiv.html b/devdocs/html/element%2Fdiv.html new file mode 100644 index 00000000..ef3188c6 --- /dev/null +++ b/devdocs/html/element%2Fdiv.html @@ -0,0 +1,129 @@ +<header><h1><div>: The Content Division element</h1></header><div class="section-content"><p>The <code><div></code> <a href="../index">HTML</a> element is the generic container for flow content. It has no effect on the content or layout until styled in some way using <a href="https://developer.mozilla.org/en-US/docs/Glossary/CSS">CSS</a> (e.g. styling is directly applied to it, or some kind of layout model like <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_flexible_box_layout">Flexbox</a> is applied to its parent element).</p></div> +<h2 id="try_it">Try it</h2> +<div class="section-content"> +<iframe class="interactive is-tabbed-standard-height" height="200" src="https://interactive-examples.mdn.mozilla.net/pages/tabbed/div.html" title="MDN Web Docs Interactive Example" loading="lazy"></iframe> <p>As a "pure" container, the <code><div></code> element does not inherently represent anything. Instead, it's used to group content so it can be easily styled using the <a href="../global_attributes#class"><code>class</code></a> or <a href="../global_attributes#id"><code>id</code></a> attributes, marking a section of a document as being written in a different language (using the <a href="../global_attributes#lang"><code>lang</code></a> attribute), and so on.</p> +</div> +<h2 id="attributes">Attributes</h2> +<div class="section-content"> +<p>This element includes the <a href="../global_attributes">global attributes</a>.</p> <div class="notecard note" id="sect1"> <p><strong>Note:</strong> The <code>align</code> attribute is obsolete; do not use it anymore. Instead, you should use CSS properties or techniques such as <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_grid_layout">CSS Grid</a> or <a href="https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Flexbox">CSS Flexbox</a> to align and position <code><div></code> elements on the page.</p> </div> +</div> +<h2 id="usage_notes">Usage notes</h2> +<div class="section-content"><ul> <li>The <code><div></code> element should be used only when no other semantic element (such as <a href="article"><code><article></code></a> or <a href="nav"><code><nav></code></a>) is appropriate.</li> </ul></div> +<h2 id="accessibility_concerns">Accessibility concerns</h2> +<div class="section-content"><p>The <code><div></code> element has <a href="https://www.w3.org/TR/wai-aria-1.2/#generic" target="_blank">an implicit role of <code>generic</code></a>, and not none. This may affect certain ARIA combination declarations that expect a direct descendant element with a certain role to function properly.</p></div> +<h2 id="examples">Examples</h2> + +<h3 id="a_simple_example">A simple example</h3> +<div class="section-content"> +<div class="code-example"> +<p class="example-header"><span class="language-name">html</span></p> +<pre data-signature="36M3KELsnVnPdTx5sHKAJZGV93N/hy5EaNxr0KbJNYE=" data-language="html"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span><span class="token punctuation">></span></span> + <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>p</span><span class="token punctuation">></span></span> + Any kind of content here. Such as <span class="token entity named-entity">&lt;</span>p<span class="token entity named-entity">&gt;</span>, <span class="token entity named-entity">&lt;</span>table<span class="token entity named-entity">&gt;</span>. You name it! + <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>p</span><span class="token punctuation">></span></span> +<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span> +</pre> +</div> <h4 id="result">Result</h4> +<div class="code-example" id="sect2"> + +<iframe class="sample-code-frame" title="A simple example sample" id="frame_a_simple_example" width="650" height="60" src="https://live.mdnplay.dev/en-US/docs/Web/HTML/Element/div/runner.html?id=a_simple_example" loading="lazy"></iframe> +</div> +</div> +<h3 id="a_styled_example">A styled example</h3> +<div class="section-content"> +<p>This example creates a shadowed box by applying a style to the <code><div></code> using CSS. Note the use of the <a href="../global_attributes#class"><code>class</code></a> attribute on the <code><div></code> to apply the style named <code>"shadowbox"</code> to the element.</p> <h4 id="html">HTML</h4> <div class="code-example"> +<p class="example-header"><span class="language-name">html</span></p> +<pre data-signature="8Atj2IB2DUFT3/Uh5/nswsCjCj65JEBrczk84bXOqFo=" data-language="html"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>shadowbox<span class="token punctuation">"</span></span><span class="token punctuation">></span></span> + <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>p</span><span class="token punctuation">></span></span>Here's a very interesting note displayed in a lovely shadowed box.<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>p</span><span class="token punctuation">></span></span> +<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span> +</pre> +</div> <h4 id="css">CSS</h4> <div class="code-example"> +<p class="example-header"><span class="language-name">css</span></p> +<pre data-signature="Bm0kShsX2T/fBmMElg2SlJqAm6aGZr/xPRuHaFLt/u4=" data-language="css"><span class="token selector">.shadowbox</span> <span class="token punctuation">{</span> + <span class="token property">width</span><span class="token punctuation">:</span> 15em<span class="token punctuation">;</span> + <span class="token property">border</span><span class="token punctuation">:</span> 1px solid #333<span class="token punctuation">;</span> + <span class="token property">box-shadow</span><span class="token punctuation">:</span> 8px 8px 5px #444<span class="token punctuation">;</span> + <span class="token property">padding</span><span class="token punctuation">:</span> 8px 12px<span class="token punctuation">;</span> + <span class="token property">background-image</span><span class="token punctuation">:</span> <span class="token function">linear-gradient</span><span class="token punctuation">(</span>180deg<span class="token punctuation">,</span> #fff<span class="token punctuation">,</span> #ddd 40%<span class="token punctuation">,</span> #ccc<span class="token punctuation">)</span><span class="token punctuation">;</span> +<span class="token punctuation">}</span> +</pre> +</div> <h4 id="result_2">Result</h4> +<div class="code-example" id="sect3"> + +<iframe class="sample-code-frame" title="A styled example sample" id="frame_a_styled_example" width="650" height="120" src="https://live.mdnplay.dev/en-US/docs/Web/HTML/Element/div/runner.html?id=a_styled_example" loading="lazy"></iframe> +</div> +</div> +<h2 id="technical_summary">Technical summary</h2> +<div class="section-content"><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>, <a href="../content_categories#palpable_content">palpable content</a>.</td> </tr> <tr> <th scope="row">Permitted content</th> <td> <a href="../content_categories#flow_content">Flow content</a>.<br>Or (in <a href="https://developer.mozilla.org/en-US/docs/Glossary/WHATWG">WHATWG</a> HTML): If the parent is a <a href="dl"><code><dl></code></a> element: one or more <a href="dt"><code><dt></code></a> elements followed by one or more <a href="dd"><code><dd></code></a> elements, optionally intermixed with <a href="script"><code><script></code></a> and <a href="template"><code><template></code></a> elements. </td> </tr> <tr> <th scope="row">Tag omission</th> <td>None, both the starting and ending tag are mandatory.</td> </tr> <tr> <th scope="row">Permitted parents</th> <td> Any element that accepts <a href="../content_categories#flow_content">flow content</a>.<br>Or (in <a href="https://developer.mozilla.org/en-US/docs/Glossary/WHATWG">WHATWG</a> HTML): <a href="dl"><code><dl></code></a> element. </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/generic_role">generic</a></code></td> </tr> <tr> <th scope="row">Permitted ARIA roles</th> <td>Any</td> </tr> <tr> <th scope="row">DOM interface</th> <td><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLDivElement"><code>HTMLDivElement</code></a></td> </tr> </tbody> </table></div></figure></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-div-element">HTML Standard <br><small># the-div-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>div</code></th> +<td class="bc-supports-yes">1</td> +<td class="bc-supports-yes">12</td> +<td class="bc-supports-yes">1</td> +<td class="bc-supports-yes">Yes</td> +<td class="bc-supports-yes">15</td> +<td class="bc-supports-yes">1</td> +<td class="bc-supports-yes">4.4</td> +<td class="bc-supports-yes">18</td> +<td class="bc-supports-yes">4</td> +<td class="bc-supports-yes">14</td> +<td class="bc-supports-yes">1</td> +<td class="bc-supports-yes">1.0</td> +</tr> +<tr> +<th><code>align</code></th> +<td class="bc-supports-yes">1</td> +<td class="bc-supports-yes">12</td> +<td class="bc-supports-yes">1</td> +<td class="bc-supports-yes">Yes</td> +<td class="bc-supports-yes">15</td> +<td class="bc-supports-yes">3</td> +<td class="bc-supports-yes">4.4</td> +<td class="bc-supports-yes">18</td> +<td class="bc-supports-yes">4</td> +<td class="bc-supports-yes">14</td> +<td class="bc-supports-yes">2</td> +<td class="bc-supports-yes">1.0</td> +</tr> +</tbody> +</table></div> +<h2 id="see_also">See also</h2> +<div class="section-content"><ul> <li>Semantic sectioning elements: <a href="section"><code><section></code></a>, <a href="article"><code><article></code></a>, <a href="nav"><code><nav></code></a>, <a href="header"><code><header></code></a>, <a href="footer"><code><footer></code></a> +</li> <li> +<a href="span"><code><span></code></a> element for styling of phrasing content</li> </ul></div><div class="_attribution"> + <p class="_attribution-p"> + © 2005–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/div" class="_attribution-link">https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div</a> + </p> +</div> |
