DIV html tag and its main advantage
The DIV tag is used mainly for laying of web page and to apply alignment and style to a particular section of a document. We normally use tables to align pages. We use div tags to take control of total page layout easily. Div tag is very easy to understand if you follow me in this lesson.
The basic syntax of div tag is:
<DIV> </DIV>
I will explain this div tag with an example. Type below code in a notepad and save as .html and open it using any browser software. You will get two boxes opposite side and left some place in between boxes. So you can place different sized sections in single page without using table. You can control total page by using simple div tags. If you use css with div tags, you can beautifully layout pages.
<html>
<head>
<title>Learning about DIV tag – Laying out a web page without using table </title>
</head>
<body>
<div style=”border: thin solid 000000; width:45%; float: left”>
This div is placed left
</div>
<div style=”border: thin solid 000000; width:45%; float: right”>
This div is placed right
</div>
</body>
</html>
I have used float in both the div tags to place one to left and another to right. You can change the back ground colour of both DIVs with different colours, different sizes, different font, different height using style attribute. Managing DIVs are very easy with cascading style sheets. We discuss about style sheets in further lessons.
You can ask me any type of question about div tags by sending a message. You may get little confusion to understand div concept. You will enjoy laying pages after getting idea of using div tags.
Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.

Comments
No comments yet.
Leave a comment