Basics: How to create a DIV
Friday, March 13th, 2009We always start a div tag like this:
<div id=”divname“>
This is the opening tag, which needs to include the ID (name) or class. If you are only having a single div of this style then it would only require an ID, if you were going to style lots of DIVS the same then you would give it a class. What ever you use, be it a class or an ID make sire you call it something useful. For example, if its a login box you would call it loginbox. We will set up the class for the div in a few moments. First you need to close the div on your page. Make sure you close it after any content that it needs to contain. For example, if its a login box as mentioned above, you would open the div, enter the login box html, then close the div.
Style it!
Now you’ve got a div, but it doesn’t look like anything. So lets style it! I am going to give my login box height, width, a border and a background color.
}
#loginbox
height:200px;
width:200px;
border:1px solid #999999;
background-color:#EEEEEE;
}
I have highlighted the main parts that you need to make sure are included. Hopefully the styles are self explanatory with the exception of the border which has multiple values..1px solid #999999. The 1px is the border line width, solid is the type of border (e.g solid,dashed etc..) #999999 is the color of the border.
I hope this helps you create a div !

