totn HTML

HTML: <div> tag

This HTML tutorial explains how to use the HTML element called the <div> tag with syntax and examples.

Description

The HTML <div> tag defines a generic container in an HTML document that is generally used to group elements. This tag is also commonly referred to as the <div> element.

Syntax

In HTML, the syntax for the <div> tag is:

<body>
<div>
</div>
</body>

Attributes

In addition to the Global Attributes, the following is a list of attributes that are specific to the <div> tag:

Attribute Description HTML Compatibility
align Alignment of the content Obsolete in HTML5, use CSS

Note

  • The HTML <div> element is found within the <body> tag.
  • The <div> tag is generally used to group elements together.

Browser Compatibility

The <div> tag has basic support with the following browsers:

  • Chrome
  • Android
  • Firefox (Gecko)
  • Firefox Mobile (Gecko)
  • Internet Explorer (IE)
  • Edge Mobile
  • Opera
  • Opera Mobile
  • Safari (WebKit)
  • Safari Mobile

Example

We will discuss the <div> tag below, exploring examples of how to use the <div> tag in HTML5, HTML 4.01 Transitional, XHTML 1.0 Transitional, XHTML 1.0 Strict, and XHTML 1.1.