HTML/CSS - 3 Column Page Layout
1 post
Page 1 of 1
OK, this is a simple 3 column html page layout with 5 sections.
Section 1: Header
Section 2: Left Column
Section 3: Center Column
Section 4: Right Column
Section 5: Footer
The CSS
Now dealing with column driven webpages using css is a pain.
Say you want to add a border to one of the section. Well you can, but it will throw off the layout of the page.
So if you add a border to the Left or Right or Center column, you will have to adjust the Margin of the CSS for that element as well.
Section 1: Header
Section 2: Left Column
Section 3: Center Column
Section 4: Right Column
Section 5: Footer
The CSS
Code: Select all
The HTML
<style type="text/css">
body{
margin:0;
padding:0;
line-height: 1.5em;
}
b{font-size: 110%;}
em{color: red;}
#wrapper{
width: 840px;
margin: 0 auto;
}
#header{
background: #ff4800;
height: 90px;
}
#header h1{
margin: 0;
padding-top: 15px;
}
#contentmain{
float: left;
width: 100%;
background: #fff1b9;
}
#maincolumn{
margin: 0 190px 0 180px;
}
#leftcolumn{
float: left;
width: 180px;
margin-left: -839px;
background: #fff1b9;
border-right: 1px solid #000000;
}
#rightcolumn{
float: left;
width: 190px;
margin-left: -191px;
background: #fff1b9;
border-left: 1px solid #000000;
}
#footer{
clear: left;
width: 100%;
background: #ff4800;
color: #fff;
text-align: center;
padding: 4px 0;
}
#footer a{
}
.inner{
margin: 10px;
margin-top: 0;
height:400px;
}
</style>
Code: Select all
The Fully coded page
<body>
<div id="wrapper">
<div id="header"><div class="innertube"><h1>CSS 3 Column Layout</h1></div></div>
<div id="contentmain">
<div id="maincolumn">
<div class="inner"><b>Content Column:</b></div>
</div>
</div>
<div id="leftcolumn">
<div class="inner"><b>Left Column:</b></div>
</div>
<div id="rightcolumn">
<div class="inner"><b>Right Column:</b></div>
</div>
<div id="footer"><a href="http://www.codenstuff.com">Codenstuff.com</a></div>
</div>
</body>
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>CSS 3 Column Layout</title>
<style type="text/css">
body{
margin:0;
padding:0;
line-height: 1.5em;
}
b{font-size: 110%;}
em{color: red;}
#wrapper{
width: 840px;
margin: 0 auto;
}
#header{
background: #ff4800;
height: 90px;
}
#header h1{
margin: 0;
padding-top: 15px;
}
#contentmain{
float: left;
width: 100%;
background: #fff1b9;
}
#maincolumn{
margin: 0 190px 0 180px;
}
#leftcolumn{
float: left;
width: 180px;
margin-left: -839px;
background: #fff1b9;
border-right: 1px solid #000000;
}
#rightcolumn{
float: left;
width: 190px;
margin-left: -191px;
background: #fff1b9;
border-left: 1px solid #000000;
}
#footer{
clear: left;
width: 100%;
background: #ff4800;
color: #fff;
text-align: center;
padding: 4px 0;
}
#footer a{
}
.inner{
margin: 10px;
margin-top: 0;
height:400px;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="header"><div class="innertube"><h1>CSS 3 Column Layout</h1></div></div>
<div id="contentmain">
<div id="maincolumn">
<div class="inner"><b>Content Column:</b></div>
</div>
</div>
<div id="leftcolumn">
<div class="inner"><b>Left Column:</b></div>
</div>
<div id="rightcolumn">
<div class="inner"><b>Right Column:</b></div>
</div>
<div id="footer"><a href="http://www.codenstuff.com">Codenstuff.com</a></div>
</div>
</body>
</html>

Now dealing with column driven webpages using css is a pain.
Say you want to add a border to one of the section. Well you can, but it will throw off the layout of the page.
So if you add a border to the Left or Right or Center column, you will have to adjust the Margin of the CSS for that element as well.
1 post
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023