<div>

  • Revision slug: HTML/Element/div
  • Revision title: div
  • Revision id: 1761
  • Created:
  • Creator: jswisher
  • Is current revision? No
  • Comment 4 words added, 8 words removed

Revision Content

The Document Division (<div>) HTML element is generic container for flow content, which does not inherently represent anything. It can be used to group elements for styling purposes (using the class or id attributes), or because they share attribute values, such as lang. It should be used only when no other semantic element (such as {{ HTMLElement("article") }} or {{ HTMLElement("nav") }}) is appropriate.

Usage context

Content categories Flow content.
Permitted content Zero or more {{ HTMLElement("style") }} elements, followed by flow content.
Tag omission None, must have both a start tag and an end tag.
Permitted parent elements Any element that accepts flow content.
Normative document HTML 5, section 4.5.13; HTML 4.01, section 7.5.4

Attributes

Like all other HTML elements, this element has the global attributes.

In {{ HTMLVersionInline("5") }}, the align attribute on <div> is {{ obsolete_inline() }}.

DOM interface

This element implements the HTMLDivElement interface.

Examples

<div>
  <p>Any kind of content here. Such as '<p>', '<table>'. You name it!</p>
</div> 

Result

Any kind of content here. Such as <p>, <table>. You name it!

See also

  • Semantic sectioning elements: {{ HTMLElement("section") }}, {{ HTMLElement("article") }}, {{ HTMLElement("nav") }}, {{ HTMLElement("header") }}, {{ HTMLElement("footer") }}
  • {{ HTMLElement("span") }} element for styling of phrasing content

Revision Source

<p>The Document Division (&lt;div&gt;) HTML element is generic container for flow content, which does not inherently represent anything. It can be used to group elements for styling purposes (using the <strong>class</strong> or <strong>id</strong> attributes), or because they share attribute values, such as <strong>lang</strong>. It should be used only when no other semantic element (such as {{ HTMLElement("article") }} or {{ HTMLElement("nav") }}) is appropriate.</p>
<h2>Usage context</h2>
<table class="standard-table"> <tbody> <tr> <td>Content categories</td> <td><a href="/en/HTML/Content_categories#Flow_content" title="en/HTML/Content categories#Flow content">Flow content</a>.</td> </tr> <tr> <td>Permitted content</td> <td>Zero or more {{ HTMLElement("style") }} elements, followed by <a href="/en/HTML/Content_categories#Flow_content" title="en/HTML/Content categories#Flow content">flow content</a>.</td> </tr> <tr> <td>Tag omission</td> <td>None, must have both a start tag and an end tag.</td> </tr> <tr> <td>Permitted parent elements</td> <td>Any element that accepts <a href="/en/HTML/Content_categories#Flow_content" title="en/HTML/Content categories#Flow content">flow content</a>.</td> </tr> <tr> <td>Normative document</td> <td><a class=" external" href="http://www.w3.org/TR/html5/grouping-content.html#the-div-element" title="http://www.w3.org/TR/html5/grouping-content.html#the-div-element">HTML 5, section 4.5.13</a>; <a class=" external" href="http://www.w3.org/TR/html401/struct/global.html#h-7.5.4" title="http://www.w3.org/TR/html401/struct/global.html#h-7.5.4">HTML 4.01, section 7.5.4</a></td> </tr> </tbody>
</table>
<h2>Attributes</h2>
<p>Like all other HTML elements, this element has the <a href="../../../../en/HTML/Global_attributes" rel="internal">global attributes</a>.</p>
<p>In {{ HTMLVersionInline("5") }}, the <strong>align</strong> attribute on <code>&lt;div&gt;</code> is {{ obsolete_inline() }}.</p>
<h2>DOM interface</h2>
<p>This element implements the <code><a href="/en/DOM/HTMLDivElement" title="en/DOM/HTMLDivElement">HTMLDivElement</a></code> interface.</p>
<h2>Examples</h2>
<pre class="brush: html">&lt;div&gt;
  &lt;p&gt;Any kind of content here. Such as '&lt;p&gt;', '&lt;table&gt;'. You name it!&lt;/p&gt;
&lt;/div&gt; 
</pre>
<h4>Result</h4>
<div>
<p>Any kind of content here. Such as &lt;p&gt;, &lt;table&gt;. You name it!</p>
</div>
<h2>See also</h2>
<ul> <li>Semantic sectioning elements: {{ HTMLElement("section") }}, {{ HTMLElement("article") }}, {{ HTMLElement("nav") }}, {{ HTMLElement("header") }}, {{ HTMLElement("footer") }}</li> <li>{{ HTMLElement("span") }} element for styling of phrasing content</li>
</ul>
Revert to this revision