HTML <div> tag

Updated: 11/16/2019 by Computer Hope
HTML div tag

When writing in HTML, the <div> tag is a block element used to divide or section off content on a web page. It is useful for grouping block-level elements together so they can be formatted simultaneously using CSS. When adding text to a <div> tag, if the text length is longer than the <div> width, the text automatically wraps to the next line.

The following sections contain information about this tag including an example of it in use, and related attributes and browser compatibility.


The <div> tag should only be used when there is not a more appropriate element, such as <nav> or <article>.

Example of <div> code

<div style="color:#ff9900; border-style:solid; border-width:2px;border-color:black;">
<h3>This content is in its own &lt;div&gt; element</h3>
<p>You can put any element into a div, which is excellent.</p>

Example result

This content is in its own <div> element

You can put any HTML element into a div, which is excellent.

Deprecated attributes

Within an HTML tag, an attribute dictates certain aspects of an HTML element. Attributes are made up of a name and value pair; all tags support standard attributes. Every attribute unique to the <div> tag is deprecated, meaning that it may function currently, but is not supported in going forward. In this case, CSS should be used in place of this attribute.

Attribute Description
align Designates the alignment of the content within a <div>


Edge Internet Explorer Firefox Safari Opera Chrome
All versions All versions All versions All version All versions All versions

Browser, Compatibility, Container tag, Content, Image, Table, Text, Web design terms