HTML div tag
HTML <div> element is a block level element which contains the content or other elements. This element is nothing on its own. It is useful when used with class, title attributes.
<div>
<p>This block has content and may have other elements.It can be designed using css poperties.
Height and width can also be defined for it.</p>
</div>
<div>
<p>This is the secong block of content. This block can also be designed.</p>
</div>
</>
This block has content and may have other elements.It can be designed using css poperties. Height and width can also be defined for it.
This is the secong block of content. This block can also be designed.
Tag Uses
Specific uses of <div> tagActually, it is used to style a group of its elements using CSS.The following example styles all paragarphs instead of styling the paragarphs separately.
div should only be used when no other element is suitable for the content. For example, we use <nav> element for navigation bar. But div is a generic type element.
Tag omission
Both opening and closing tags are necessary for the div element.
Global Attributes
All global attributes are applicable on div element.
Next Previous
Was this article helpful?