HTML <div> Tag

Description

The <div> HTML element is a universal block element and is designed to group document elements in order to change the appearance of content through styles. To do this, add the class or id attribute with the name of the class or identifier.
As with other block elements, the contents of the <div> always begin with a new line, and line breaks are also added after it.

Properties

Permitted Parents
Any element that accepts flow content
Content
Block, inline and text
Start/End Tags
Start tag: required, End tag: required

Example

<div style="background-color:orange;text-align:center">
<p>Navigation section</p>
</div>
<div style="border:1px solid black">
<p>Content section</p>
</div>

Attributes

Attribute Definition
align

Specifies the alignment of the content inside a div element.
Possible Values:

  • left
  • right
  • center
  • justify

-Deprecated-

Global Attributes

The <div> tag also supports the Global Attributes in HTML5

Event Attributes

The <div> tag also supports the Event Attributes in HTML5

Browser Support

Desktop
Explorer Edge Chrome Firefox Opera Safari
YesYesYes1YesYes
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
YesYes4YesYesYes