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.
-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
The following table will show you the current browser support for the HTML <div>
tag.
Desktop | |||||
12 | 1 | 1 | 15 | 1 |
Tablets / Mobile | |||||
18 | 4 | 14 | 1 | 1 | 4.4 |
Last updated by CSSPortal on: 30th September 2023