Why we use DIV in HTML document?

DIV is very necessary tag in Modern HTML, which are used to create and structure a HTML document or layout. DIV tag defines a section in HTML document and they are defines a generic block-level container, which means that they have no additional formatting method. We can manage DIV with the CSS. Please follow the example below.

HTML Code:

<div class="main">
	<div class="header">Heading Goes Here</div>
	<div class="content">Content1</div>
	<div class="content">Content2</div>
	<div class="content">Content3</div>
	<div class="footer">Footer Content</div>
</div>

CSS Code:

.main
{
width:390px;
}
.header
{
width:380px;
background-color:#ffffcd;
text-align:center;
height:45px;
line-height:45px;
font-weight:bold;
padding:5px;
}
.content
{
float:left;
background-color:#fecccb;
padding:5px;
height:126px;
width:120px;
}
.footer
{
width:380px;
background-color:#cdffcc;
text-align:center;
height:55px;
line-height:55px;
padding:5px;
clear:both;
}

Browser view:
Use Div in HTML file

VN:F [1.9.22_1171]
Rating: 7.8/10 (6 votes cast)
VN:F [1.9.22_1171]
Rating: +2 (from 2 votes)
Why we use DIV in HTML document?, 7.8 out of 10 based on 6 ratings

This entry was posted in Advanced HTML - CSS. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>