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
orid
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
Chrome | Edge | Firefox | IE | Opera | Safari |
---|---|---|---|---|---|
Yes | Yes | Yes | Yes | Yes | Yes |
Mobile
Android Webview | Chrome Android | Firefox Android | Opera Android | iOS Safari | Samsung Internet |
---|---|---|---|---|---|
Yes | Yes | Yes | Yes | Yes | Yes |