September 12th in Design, PHP Scripts by pbu .
How to design 3 Column Website Layout with Top Navigation Menu in CSS
CSS as we go deeper and deeper it gets harder and harder to understand, especially margins, padding and floats could be confusing at times as well. I am going to post here the tutorial to make a very simple CSS website layout (skeleton) with
- Container
- Header
-Top Navigation Menu
- Left Navigation Menu
- Right Navigation menu
- Content Part
- Footer
All elegantly stacked one by one with divs and with css stylesheet. This is a very basic skeleton. The most important css code are highlighted in the picture. The basic concept is shown below.
Code Flow
Notice carefully the div stacked. A container holds all those header, content, and menus.
<div id=container>
<div id="header">
<h2>Header</h2>
</div>
<div id="topnav-container">
<ul id="topnav">
<li> <a href="#">Home</a> </li>
<li> <a href="#">Categories</a> </li>
<li> <a href="#">Services</a> </li>
<li> <a href="#">About us</a> </li>
<li> <a href="#">Contact us</a> </li>
</ul>
</div>
<div id="leftnav">
This is a left navigation bar.
This is a left navigation bar
This is a left navigation bar
</div>
<div id="rightnav">
This is a right navigation bar
</div>
<div id="content">
<p>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam
</p>
</div>
<div id="footer">
<h2>Footer</h2>
</div>
</div>
CSS Code
The CSS code is shown below for the above skeleton.
#container {
margin: 10px auto;
width: 95%;
border: 1px solid gray;
}
#header {
padding: 3px;
border-bottom: 1px solid gray;
}
#topnav-container {
border-bottom: 1px solid gray;
padding: 4px 0;
background: #e0e0e0;
}
#topnav {
margin:0;
padding: 0;
}
#topnav li {
display: inline;
list-style: none;
}
#topnav li a {
text-decoration: none;
padding: 0px 5px;
color: #333;
}
#leftnav {
float: left;
width:150px;
padding: 5px;
margin:0;
}
#rightnav {
width: 150px;
float:right;
padding: 5px;
margin:0;
}
#content
{
margin: 0 180px 0 180px;
padding: 1em;
border-left: 1px solid gray;
border-right: 1px solid gray;
font-family: "Times New Roman",sans-serif ,arial, helvetica;
font-size: 1.0em;
line-height: 1.6em;
}
#footer {
clear:both;
padding: 0 3px;
border-top: 1px solid gray;
}
Download source code:3colcsstut.zip
Similar Posts:
- CSS Tutorial: How to Design Round Corner Boxes
- CSS Tutorial & Useful Tips for Beginners
- Changing Quote and Code Tags in WordPress
- Adding border to images in WordPress post!
- 25+ Best Premium CSS Navigation Menus for Web Developers
- Changing Default Font in TinyMCE Editor
- Remove text wrap around image in wordpress
- 30+ Best jQuery Tutorials & Plugins for Beginners
- WordPress – How to create a login protected page?
- Paypal return url issue with missing GET parameters



January 27, 2009
Very nice job first off. I do have a question for you… I tried using this as a outline for my design tweaked it a bit to my specs but I can seem to get rid of the horizontal lines that show just above the footer and just below the nav bar. I’ve checked all of the css and html settings. I just can’t seem to find the issue.
Thanks in advanced for any help!
April 6, 2010
@John S, Have you tried setting margins or padding of those s to 0 or I you mean not
April 7, 2010
I studied the css tutorial and I really learned a lot. I think my next homepage will be a lot better than my first one.
February 9, 2011
hello there and thank you for your info – I have definitely picked up anything new from right here. I did however expertise several technical points using this web site, since I experienced to reload the website lots of times previous to I could get it to load correctly. I had been wondering if your web hosting is OK? Not that I am complaining, but sluggish loading instances times will often affect your placement in google and can damage your high quality score if advertising and marketing with Adwords. Anyway I am adding this RSS to my email and could look out for a lot more of your respective exciting content. Make sure you update this again very soon..
February 10, 2011
Nice simple style code a good start for a web design, thanks.
August 12, 2011
I have really enjoyed surfing around this site. After all I’ll be subscribing to your feed and I hope you write again soon!