CSS: Layout Using Div Tags
<div> is a page division. It is the CSS way to create a page layout.
This can then be inserted into your html
><div id = "my_first_div"> This is text inside my division </div>
You can use CSS codes to arrange your divs on the page.
The CSS code I use
Below is the simplified CSS I use in class. 3 columns, header and footer fixed.
You can copy and paste this code into your CSS document and adjust it to suit your own needs
The #box div is the container that the other divs are put into. It should be invisible. margin-left:auto; and margin-right:auto; are used to center the layout on the page.
#menuand #main use float:left; to place them next to each other. #submenu uses float:right; to align it to the right.
#foot needs clear:both; A lot of students forget this. It is needed to clear the float command from your #menu #main and #submenu divs
The HTML code for the layout
This is the simplified code in HTML for the layout. You can copy and paste it into dreamweaver, but make sure the div names are the same as those in your CSS file:
<div id = "box">
<div id = "head"> This is the head </div>
<div id = "menu">This is the menu </div>
<div id = "main"> This is the main content </div>
<div id = "submenu"> This is the submenu </div>
<div id = "foot"> This is the footer </div>
Remember, all your <div> tags must go inside the <div id = "box"> tag.
To place your <div> in the absolute center of the screen
The following code will place your #box container div in the horizontal and vertical middles of your page.
margin-left and margin right will always be negative half of your width and height