How to Build a Basic CSS Layout

Designing without tables by using CSS layouts is fastset
becoming the new standard on the Web because ofwidth, it leaves room for the main div to move up
theto the
benefits mentioned in my previous article. Webright of the nav div, thus creating the two-column
browserseffect.
used these days are now able to render web pagesThe div#main style includes the margin-left: 30% rule
proficiently. In this article I will endeavor to create ato
basic 2 column CSS layout which you can use forkeep the main text aligned in a neat column instead
futureof
design projects.Web Page:spreading out below the nav column. The main div's
Style Sheet: Divide your page into sections - the divleft
id tagsmargin is set to a value slightly larger than the width
allows you to create distinct divisions on your webof
page.the nav div.Style Sheet
They are identified with a unique id. You can thenlinks are placed elsewhere on the page they will
add ainherit
style (css selector) that specifically applies to the divthe same properties as above..a blue link that hovers
of that id. Remember to include the DOCTYPE (toto
render yourred. What if you wish to create another set of links
page accurately in the browsers) and meta tagsthat
(enablesare a different color and on passing your mouse
search engines to spider your pages).wrapper: is theover them
div that wraps around all the other divsthey are underlined.4. Create the bottom navigation -
like a container for the page elements.to include this in the
header: defines the top banner of the pagesection of the page, I use div#footer and
main: defines the main content of the pagecode each link accordingly. To make the list go
nav: defines the navigation of the pagehorizontally I use: display: inline;Now that I have
footer: defines the footer and sub-navigation of thefinished creating my style sheet I want to
page2. Create the CSS code - the CSS code stylesshorten the code on page by linking it to my
the page as a centered 2 column CSS layout with aexternal style
navigation bar and a footer. The div#wrapper stylesheet. Here's how:4. Create an external style sheet -
creates the centered box which acts as a containercopy and paste all the
for the rest of the page content. The width: 80%css code (without these tags: ) into notepad and
rule sets the width of the div. Thelabel it something like
background-color:#FFFFFF rule creates a white"style sheet". Place this style sheet between the
background for the div. The margin-top: 50px andhead tags
margin-bottom: 50px rules create a space of 50of your web page.This will reduce the code on your
pixels forpage so it will load fast
the top and bottom margins for the div itself.Theplus the search engines can more easily spider your
proper way to center a block-level element with CSSweb
ispage.4. Add content to your page - after you have
to set margin-left: auto and margin-right: auto. Thisgot your page
instructs the browser to automatically calculate equallooking correctly, you can add more content to it.
margins for both sides, thus centering the div. TheAdjustments can easily be made to any style on the
border:page (or
thin solid #000000 rule adds a border around theyour whole site) by simply editing one style sheet.5.
outer div.Upload your files - be sure to upload your web pages
The rest of the CSS code styles the divs for theand
header,style sheet to the root directory of your server.6.
footer, nav, and main content.The div#header andValidate your code - be sure to validate your xhtml
div#footer styles set margins andcode: and css code:
padding for those divs. In addition, div#headerand make corrections
includeswhere necessary.7. Check browser compatibility and
the text-align: center rule to center the header text,screen resolution -
andcheck that your page renders well in the popular
div#footer includes the border-top: thin solidbrowsers
#000000 rule(IE6, NN7, Firefox)If you are beginning with CSS
to create a border along the top edge of the div tolayouts, implement then
replaceslowly by making small changes to your pages i.e.
the horizontal rule above the footer in thecreating
table-baseda style sheet for your main headers and fonts only.
layout.The div#nav and div#main styles create theAs you
two columns inbecome more familiar with CSS you may eventually
the middle of the centered box. In the div#navbuild all
style, theyour future sites with CSS layouts.Resources:Basic
float: left rule pushes the div to the left side of itsCSS layout
parent element (the wrapper div), and the width:Style Sheet
25% ruleof CSS
sets the div's width to 25 percent of the parentDrost is the Certified Internet Webmaster (CIW)
element.owner and author of Affordable
With the nav div floated to the left and limited to aWeb Site Design and Web Hosting.