HTML / HTML Tags

HTML <Div> Tag

Dec 12, 2022
1 min read
HTML div Tag

Definition

The <div> tag defines a container within an HTML document that has no semantic meaning on its own.

Example

<!DOCTYPE html>
<html>
<head>
    <title>HTML Title Element goes here.</title>
</head>
<body>
    <h1>Displayed Page Title</h1>
    <div class="paragraphgroup">
      <p>A paragraph goes here.</p>
      <p>A paragraph goes here.</p>
      <p>A paragraph goes here.</p>
    <div>
</body>
</html>

Usage

  • The <div> element must have an opening and closing tag.
  • It can be used as a container for HTML elements.
  • It can be easily styled using the class or id attribute.

Attributes

The <div> element supports the Event Attributes and Global Attributes.

Best Practices

  • The HTML5 specification strongly recommends that the <div> element only be used when no other element is more suitable. The use of semantic elements in place of <div> is more accessible and more easily maintained by developers.

Specification

Browser Support

Desktop

ChromeEdgeFirefoxIEOperaSafari
YesYesYesYesYesYes

Mobile

Android WebviewChrome AndroidFirefox AndroidOpera AndroidiOS SafariSamsung Internet
YesYesYesYesYesYes