Tag <div> HTML Reference



Example

A section in a document that will be displayed in green:

<div style="color:#00FF00">
  <h3>This is a header</h3>
  <p>This is a paragraph.</p>
</div>

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

1. Definition and Usage

The <div> tag defines a division or a section in an HTML document.

The <div> tag is used to group block-elements to format them with styles.


2. Tips and Notes

Tip: The <div> element is very often used together with CSS, to layout a web page.

Note: By default, browsers always place a line break before and after the <div> element. However, this can be changed with CSS.


3. Differences Between HTML 4.01 and HTML5

The align attribute not supported in HTML5.

The align attribute is deprecated in HTML 4.01.


4. Optional Attributes

DTD indicates in which HTML 4.01/XHTML 1.0 DTD the attribute is allowed. S=Strict, T=Transitional, and F=Frameset.

Attribute Value Description DTD
align left
right
center
justify
Deprecated. Use styles instead.
Specifies the alignment of the content inside a <div> element
TF

5. Standard Attributes

The <div> tag supports the Standard Attributes in HTML.


6. Event Attributes

The <div> tag also supports the Standard Event Attributes in HTML.


Relative articles