How to build a webpage using CSS instead of tables for layout and positioning
A quick and simple how to that answers the common question: how do I design a tableless layout using CSS?
If you are like me, you started building web pages when code was written in notepad and HTML was everything you had to know. And if you are like me, you are coming back to site design and finding that thanks to CSS everything has changed – for the best .
In times gone, tables where the only tool you had to format your page and design a layout . The classic design was a 1 row, 2 columns table . On one cell you put your navigation menu , on the other cell you put your content .
Today the use of tables to design a layout is deprecated: tables are to be used only for their original scope, presenting data in a table format. To design layout there’s a much more powerful and flexible tool: Cascading Style Sheets, or CSS.
People not used to design with CSS may wonder how to arrange content in the page without the comfort of cells and tables. But the truth is: CSS allows you to design layouts faster, with more precision and less code than tables . Complex layouts that required nested tables are easier to code and easier to manage. And changing a few lines of codes on a single style sheet you can entirely alter the layout of all the pages of your site.
The logic of website layout design with CSS is quite easy. Mastering this powerful tool and design very complex, usable, eye catching pages is difficult and requires study and application. The scope of this tutorial is very basic : a guide you to design a simple two columns page . With a quick search on Google you’ll find lots of documents, tutorials and guides that will help you learn the more advanced uses of CSS.
Attention: in this tutorial I’ll write about the CSS code needed to design an example layout. I won’t explain in detail how CSS works, nor the many other options it gives you to fine tune every detail of every element that will appear on your page.
Let’s start. The most popular layouts you can find on the web can be represented by figure 1.

In a 2 columns layout we have an Header area (with logo and name of the website), a Navigation area (with links to the various subpages of the website), a Main Content area and a Footer area (with credits, copyright and contact details).
You used to generate the layout using the following code:
If you wanted to change something in your layout, say change from vertical navigation on the side of the page to horizontal nav bar under the header, you had to change every single page of your site.
How do we design the same layout using CSS? Using the float attribute. Using CSS you basically divide the content of your page in blocks, delimited by the /…/ tags. The float attribute allows you to place (float) a portion of your content along the right or left margin of your block. The rest of the content of that block will flow around your floating portion.
Let’s do it. We’ll need an HTML page and a CSS style sheet.
Let’s look at the HTML first.
As you can see, we have divided every logical portion of our page in blocks. As you can see, all the elements of our page (header, footer, navigation and content) are contained in a block called container, that basically is the whole page. We’ll place our elements inside the “container” space. As you can imagine, we are going to float the navigation block to the left of our “container” block.
Here’s the code to work the magic.

As I said, I won’t go into details here, explaining what every command means.
But let’s review it quickly, pointing out what interests us.
First of all we assigned the font for the pages, specifying its attribute . We also assigned a formatting to the H1 and H2 tags .
The “div#something” calls are where we assign a formatting and a specific behaviour to each of the blocks we defined in our html .
Please note the calls for navigation and content . We assigned to the navigation the “left ” property, placing it on the left side of our page. Then we defined the column width and the main content margin from the column.
Please note the “clear:left” attribute we assigned to the footer . A common mistake is forgetting this attribute to the footer. If you forget it, your footer will not be placed at the bottom of the page , but at the bottom of the main content area and on the left of your navigation area. If the navigation area is longer than your main content, it will extend below the footer. Using the “clear:left” attribute we avoid this common mistake .
You can argue that we can get to the same result with less effort and less code using tables. But remember: this is only a very quick how to, I only touched the very surface of CSS to answer the common question: how do I design a tableless page with CSS?
To give you an idea of the power of CSS, if we want to change from vertical navigation to horizontal navigation, everything we must do is change a few lines of code in our CSS and the layout of all our pages will change.
Nothing Found!
Why not submit your own content? Signup here.
-
How to Make Your Own Friendster Lay-out | By dgraphicrookie | in Web Design
A very basic step-by-step guide for making a friendster lay-out....
-
Let’s Learn: Graphic Design | By dgraphicrookie | in Web Design
As long as we have our imagination active, graphics will always be a part of our everyday lives....
-
How to Customize Your Own Website | By mboone84 | in Web Design
Are you starting a new business, and a little low on advertising funds? Or do you just want to create a website to ...
-
Success of E-commerce Website Design | By Marcbenson | in Web Design
The websites are developed with the aim of sharing information. This information exchange may be reciprocal or non-...
-
Make your Own Free Website Using Webs (Formerly Freewebs) | By jeansmith99 | in Web Design
Why do YOU want your own free website? A small business? A blog? An online store? With Webs - formerly known as Fre...
-
A traveller's guide to Pisa | By ancos | in Holidays
Pisa, Italy, is the town famous for the legendary Leaning Tower, one of the simbols of Italy. This is a little guid...
-
How to understand the languages of love: the different ways to communicate “I love you” | By ancos | in General
Everybody has a different way to communicate "I love you" and is more responsive to signals sent on the same "chann...
-
How much should I ask? A guide to pricing for freelancers. | By ancos | in Home & Online Business
Every beginning freelancer asks how much charge for a project. In this article I want to give some guidelines that ...
-
How to cook pasta the Italian way | By ancos | in Recipes
A short guide to cook Pastasciutta the Italian way. The recipe for the classic pasta col pomodoro (tomato sauce) an...








nice article.5 star.thanks for viewing my works.we can be a good partner in bukisa.
Nice Article. I've reviewed ALL your articles and decided to comment on this one so that your can get your page views up to make more money. Please take the time to review my articles and comment on one--I'd really appreciate it.....Robb
Nice article check out mine when you get a chance..... Robb