473,416 Members | 1,869 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,416 developers and data experts.

Simple Three Column Layout

Death Slaught
1,137 1GB
I will be showing you how to make a very simple but effective three column layout.

First we will begin with the HTML, or structure, of our three column layout.

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/xhtml1-strict.dtd"> 
  2.  
  3.  
  4. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  5.  
  6.  
  7.   <head>
  8.     <title></title>
  9.     <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
  10.     <link rel="stylesheet" href="style.css" />
  11.   </head>
  12.  
  13. <body>
  14.  
  15.   <div id="left">
  16.   </div>
  17.  
  18.   <div id="middle">
  19.   </div>
  20.  
  21.   <div id="right">
  22.   </div>
  23.  
  24. </body>
  25.  
  26. </html>
Depending upon what you're using each column for there are two ways to position our divisions. We will start with the easier one first.

For this exmaple we are actually going to change our HTML a little. Instead of using ids for our divisions we are going to give them all the same class. So our HTML should look like this.

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/xhtml1-strict.dtd"> 
  2.  
  3.  
  4. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  5.  
  6.  
  7.   <head>
  8.     <title></title>
  9.     <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
  10.     <link rel="stylesheet" href="style.css" />
  11.   </head>
  12.  
  13. <body>
  14.  
  15.   <div class="column">
  16.   </div>
  17.  
  18.   <div class="column">
  19.   </div>
  20.  
  21.   <div class="column">
  22.   </div>
  23.  
  24. </body>
  25.  
  26. </html>
The reason we're giving each division the same class is so it will be easier to give them all the same style from one rule.

Now we will begin with the CSS, or styles, for our three column layout.

Expand|Select|Wrap|Line Numbers
  1. .column {
  2.   float:left;
  3.   width:200px;
  4.   height:500px;
  5.   border:1px solid #000;
  6. }
The most important style here is the "float:left;". This is what makes each division sit perfectly against one another. It's really all you need to make a three column layout. The other styles are simply for visual aid. It's very simply but it does cost some customability of each division. This is where our second example comes into play.

Now we switch back to our first code.

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/xhtml1-strict.dtd"> 
  2.  
  3.  
  4. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  5.  
  6.  
  7.   <head>
  8.     <title></title>
  9.     <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
  10.     <link rel="stylesheet" href="style.css" />
  11.   </head>
  12.  
  13. <body>
  14.  
  15.   <div id="left">
  16.   </div>
  17.  
  18.   <div id="middle">
  19.   </div>
  20.  
  21.   <div id="right">
  22.   </div>
  23.  
  24. </body>
  25.  
  26. </html>
Each division having its own id makes it much easier to add specific styles to that, and only that, division. We're still going to use the same styles for each division and we do have to type a little more code, but it's worth it for customability of each division.

Expand|Select|Wrap|Line Numbers
  1. #left {
  2.   float:left;
  3.   width:200px;
  4.   height:500px;
  5.   border:1px solid #000;
  6. }
  7.  
  8. #middle {
  9.   float:left;
  10.   width:200px;
  11.   height:500px;
  12.   border:1px solid #000;
  13. }
  14.  
  15. #right {
  16.   float:left;
  17.   width:200px;
  18.   height:500px;
  19.   border:1px solid #000;
  20. }
Now you know two ways to make a three column layout, simply by using the powerful style "float:left;".
Attached Files
File Type: zip Example 1.zip (621 Bytes, 429 views)
File Type: zip Example 2.zip (644 Bytes, 375 views)
Apr 22 '08 #1
1 8875
wizardry
201 100+
hello -
with a record set query from php in mysql database how would that layout? wouldnt you need some sort of method or for loop then pass it and increment the variable passed?

if so could you show me an example?

thanks in advance for your help!
Nov 13 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Martin Gutowski | last post by:
Hi, I'm having trouble with a three-column layout that has a 'banner' across the top of them. I'd like the top to have two graphics, one flush left and one flush right. They would be in those...
1
by: TheMartian | last post by:
Three column layout using nothing but CSS (absolute positioning), renders well in IE, NS, Mozilla, camino, Opera Mac etc The test page is at http://sol4.net/3.shtml as on the above page,...
0
by: Alfred | last post by:
I essentially have the standard two column layout, but I'm running into a quirk I'm hoping someone can help with. I have one column which is the main content (75%) of the screen and the remaining...
2
by: dbasch | last post by:
Hello all, I am trying my best to create a three column form using CSS but am having no luck. It looks fine in Firefox but is mangled in IE. Here is my best attempt: <style type="text/css">...
12
by: vertigogen | last post by:
Hi I'm trying to design a simple three-column website using html and an external stylesheet. I have a header of 750px wide, navbar underneath is the same width, both centred. Now I want to...
4
by: Jim Carlock | last post by:
I'm working with three column layouts without tables. The page in question... http://www.microcosmotalk.com/images/garden/vine.asp Using clear:both; causes problems in the left and right...
3
by: =?ISO-8859-1?Q?Ney_Andr=E9_de_Mello_Zunino?= | last post by:
Hello. I seek confirmation for the reasons behind a margin-related behavior I have observed. I have set up a simple test page to illustrate the issue. The page shows a very simple 2-column...
1
by: Reiki Evolution | last post by:
This is the page that I am putting together: http://www.reiki-evolution.co.uk/draft/uk-first-degree-course-dates.htm The site consists of three columns: a sidebar floated left, a sidebar...
3
by: Mark | last post by:
Hi all I would like to create a simple two column layout - navigation on the left and content on the right. I would like the columns to have a fluid width so they can grow and shrink according...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.