Style Sheets
  Home arrow Style Sheets arrow Page 2 - DIV Based Layout with CSS
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
STYLE SHEETS

DIV Based Layout with CSS
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 263
    2004-12-21

    Table of Contents:
  • DIV Based Layout with CSS
  • The table-based approach
  • The mighty DIV tag
  • Fixed layout design with fixed boxes
  • Three-column fixed layout
  • Fixed layout design with floating boxes
  • Adding a right column
  • Liquid design with floating boxes
  • Three-column liquid layout with floating boxes

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    DIV Based Layout with CSS - The table-based approach


    (Page 2 of 9 )

    One of the most common page layouts using tables is easy to do with the ALIGN attribute. This is a left-hand navigation bar with a larger content section, directly to the right of it, building only two tables.  

    Here is the code:

    <table align=”left” width=”20%” height=”100%”>
    <tr>
    <td valign=”top”>Navigation links are placed here</td>
    </tr>
    </table>

    <table align=”right” width=”80%” height=”100%”>
    <tr>
    <td valign=”top”>Main content is placed here</td>
    </tr>
    </table>

    We build this simple two-column layout, placing the tables as mentioned above: one is located to the left and the other is located to the right. The ALIGN attribute helps us to turn complex tables into simpler ones.

    We can use this technique with nested tables too, to keep our layout easier to maintain and display, while it’s still quite appealing to search engines spiders.

    A note about this: the attributes ALIGN, WIDTH and HEIGHT are deprecated elements in HTML 4.01 (they are marked for deletion in future versions), but they aren’t likely to disappear any time soon. Currently, all browsers recognize these attributes.

    From this point on, we could attach an external style sheet that contains all the proper style declarations for each table, continuing to improve the code like this:

    <table id=”content” width=”80%” align=”right” height=”100%”>
    <tr>
    <td valign=”top”>Main content is placed here</td>
    </tr>
    </table>

    <table id=”leftnavigation” width=”20%” height=”100%”>
    <tr>
    <td valign=”top”>Navigation Links are placed here</td>
    </tr>
    </table>

    The layout is the same as before, but note the ID attribute for each table. Assigning ID contextual selectors from an external style sheet allow us to build the visual appearance for data contained into each table.

    So far, this is a simple sample for table-based layout. It can be easily expanded to more complex layouts, adding nested tables techniques and so. However, I would strongly recommend using DIV tags and CSS for page layout, as we shall see in a moment. Trust me.

    More Style Sheets Articles
    More By Alejandro Gervasio


       ·  Concerning to webpage layout, althougt tables are the most used elements, a CSS...
       · Its definately more accessible.Keep tables for tabular data, not...
       · I've read the article and esp. the last page ("Three-column liquid layout with...
       · Jacob - you could give the left and right menu div's (not cells!) fixed widths, then...
       · The nice thing about designing with tables is that the heights of all columns in a...
       · Another nice thing about designing with tables is the fact that people with...
       · In regards to the "Three-Column Liquid Layout With Floating Boxes", is it possible...
       · Hi,Regarding your question, yeap, it's possible set fixed sizes to left and...
       · Check this article out on alistapart...
       · Just define #leftcol and #rightcol in pixel width and #content width:auto - like...
       · its bad to use position/presentation words in your IDs and class names... words such...
       · Hi there,I agree with your naming concepts. It's only for example...
       · Nice attack!
       · This seems to be a trend with your articles - "only for example sake". You should...
       · Dear Sr.Your comments and suggestions are very welcome. In fact, every time I...
       · I'm not sure what youre reply means, but if anything, seperation of application...
       · I get your point of view, and it's right.I liked your naming examples, showed...
       · tried your fixed width left and right cols and it breaks in Safari. when content...
       · Regarding the solution proposed by the previous poster, that won't work on Safari,...
       · I agree with the above concept too.
       · How do I center the page as a whole when using div tags?
       · Hello,There are numerous methods to center a page so you may want to select a...
       · I pretty much followed the instructions, haven't put css in separate sheetyet but...
       · Just a little word about fixed size.Using pixel size (px) for dimension is as...
       · Thank you for commenting on my DIV-based layout article. Also, I found your opinions...
       · How do you put your CSS in a separate page and still have it work with the current...
       · Thank you for the comments on my CSS article. Regarding your question, first save...
       · Short of having a fixed width container, I wonder if its possible to use the float...
       · Thank you for commenting on my article. With reference to your question, yes,...
       · Relax, Yodah. Not everyone is designing a site for the blind.
       · Thank you for posting your the comments on my DIV-layout article. They're greatly...
       · Not only is that incorrect, but it was god-awful rude.In truth, tabled design IS...
       · this is international level class and id name
       · Thank you for the comments on my article. They're greatly...
       · Very nice article. I learn new thing today.But sometimes we need merged cells and...
       · Thank you for commenting on my article, and it’s good to know it’s been useful to...
       · I have not agree your commd
       · Thank you for posting your comments on my CSS article. And I’m glad to see it...
       · really great article! It helped me a lot to understand the concepts of div...
       · Thank you for the kind comments on my CSS article. Also, it’s good to know it’s been...
       · A table does not leave you with a fixed layout. Why not use tables and make them...
       · Thanks for posting your comments on my CSS article. Yes, liquid tables are great and...
       · This article was helpful. Thanks very much. One feature that I would like to...
       · Thank you for the kind comments on my article. Concerning your question, you may...
       · Is this possible that the header is fluid - 100%, the right and left columns are 19%...
       · Thank you for the comments on my article. Concerning your question, yes, it's...
       · With http://www.quirksmode.org/css/centering.html received a 404 not found error...
       · Thank you for commenting on my CSS article. Since the above link was posted a few...
       · DIV based design is the correct thing to do while designing a web site that should...
       · Thank you for commenting on my article. Yes, divs are by far more accessible than...
       · Hi,i have to work with CLF2, and therefore have to replace pretty much all of my...
       · Thanks for the comments on my article. Concerning your question, I suggest you to...
       · Thank you for the article. It was very useful.Table layout is much more powerful...
       · Thanks for the kind comments on my article and your insightful post. In my personal...
     

    STYLE SHEETS ARTICLES

    - Improving the Visual Presentation of a CSS D...
    - Fixing Browser Incompatibilities in a CSS Dr...
    - Building Clean Drop-Down Menus with CSS
    - Creating Hybrid Web Page Layouts with Negati...
    - Creating Three-Column Web Page Layous with N...
    - Swapping Column Positions in Web Page Layout...
    - Creating Web Page Layouts with Negative Marg...
    - Creating Gradients for Individual Containers...
    - Creating Gradients for Web Page Headers with...
    - SEO Scrolling Frames Problem Solved
    - Building Cross-Browser Background Effects wi...
    - CSS: Pseudo
    - Using PNG Images to Build Background Effects
    - CSS: Continuing the Clarification of CSS Cla...
    - CSS: Top Secret Classification






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT