Div Tag In HTML


Div Tag In HTML

<DIV> tag is used to define a section in an HTML document. It can be used to group large section of HTML elements together and format them with cascading style sheet. The closing tag </DIV> is used to indicate the end of section.

Attributes

Some important attributes of <DIV> tag are as follows

ALIGN

It specifies the alignment of the DIV. The possible values are
center, left and right. The default value is left.

STYLE

It is used to include inline cascading style sheet

Example

<DIV STYLE="background-color:blue;text-align:right">
<P>Div Layout Examples</P>
</DIV>

Now take a look at practical of this article.

Practical

Open Notepad and type the following code

<HTML>

<BODY>

<DIV STYLE="background-color:orange;text-align:center">

<P>lt's my style</P>

</DIV>

<DIV STYLE="border: 1px solid black;text-align:right ">

<P>lt is another style.</P>

</DIV>

</BODY>

</HTML>

Save the file as "Div.html"
Double click the file. The web page will appear in the browser as follows