div element



Div element is used to set/adjust the common font style, size & color for the texts in a document.
<div style="background-color:Color Name;text-align:Direction"> <p>Text</p> </div>

Example Code:

Result :

Left Aligned Text

Center Aligned Text

Right Aligned Text
  • It reduces the repetitive works done by user.
  • The text enclosed by this tag wil have the same style, color & size.
  • It inserts line breaks.
It is available in the previous versions of HTML.
It supports both Global Attributes and Event Attributes in HTML5.


It is applicable to all major browsers.

Ask Questions

Ask Question