Style Sheets
  Home arrow Style Sheets arrow Page 3 - Creating DIV-based CSS Tables
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 
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

Creating DIV-based CSS Tables
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 7
    2008-12-30

    Table of Contents:
  • Creating DIV-based CSS Tables
  • A three-column web page layout using a floating-div approach
  • Using CSS tables to create a two-column web document layout
  • Structural markup for a two-column web document layout

  • 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


    Creating DIV-based CSS Tables - Using CSS tables to create a two-column web document layout


    (Page 3 of 4 )

    Put in a simple way, building web page layouts by using CSS tables is a procedure that relies on specifying that the divs that comprise the pertinent web document must behave as typical table elements. It’s that simple.

    The crucial question that comes up here is: how can this be achieved with plain CSS code? Well, it’s possible to use the “display” property that you’ve probably utilized hundreds of times before to indicate to the browser that some selected divs must be laid out as table components.

    In this case, since I’m planning to construct a layout comprised of a main column along with a side bar, the set of CSS styles that would render this design would be the following:

    #maincol, #sidebar{

    display: table-cell;

    }

    #tablewrapper{

    border-collapse: collapse;

    display: table;

    table-layout: fixed;

    }

    #sidebar{

    width: 20%;

    padding: 10px;

    background: #eee;

    }

    #maincol{

    width: 80%;

    padding: 10px;

    }


    As shown above, here’s where the magic of CSS tables really happens! As you can see, I defined two selectors identified as “sidebar” and “maincol” respectively, which obviously are the principal containers of this two-column layout. However, you should pay attention to the code that instructs these divs to behave as table cells. The following CSS declaration:


    #maincol, #sidebar{

    display: table-cell;

    }


    tells the browser that the corresponding divs should be rendered as table cells, instead of being shown as regular containers. Besides, it’s very important to note that I created an additional “tablewrapper” div, which will be displayed as a regular HTML table, since it’s been assigned the following CSS styles:


    #tablewrapper{

    border-collapse: collapse;

    display: table;

    table-layout: fixed;

    }


    It’s hard to believe, but that’s all the CSS code required to create a simple two-column web page layout by using CSS tables. Of course, this approach doesn’t demand the use floating divs, and indeed the CSS styles are much easier to read and code. Unfortunately, Internet Explorer doesn’t completely support this technique, but as I mentioned in the introduction, it seems that the engine included into its eighth version will be completely compliant with it.

    So far, so good. At this point, you've hopefully learned the basics of using CSS tables to construct a two-column web page layout. However, this introductory example looks rather disjointed in its current incarnation, since it requires us to tie the previous CSS styles to the corresponding structural markup.

    Thus, in the section to come I’m going to put all of these elements into one single file, so you can see more clearly how they link with each other.

    Now, jump ahead and read the new few lines. We’re almost finished!

    More Style Sheets Articles
    More By Alejandro Gervasio


       · CSS tables might be over time a great improvement in the way web page are created....
     

    STYLE SHEETS ARTICLES

    - Image Replacement CSS Techniques
    - Using BlueTrip`s Success, Notice and Error C...
    - More Uses for the Thin and Caps CSS Classes ...
    - Styling Definition Lists with the BlueTrip C...
    - Styling Unordered and Ordered HTML Lists wit...
    - Using the BlueTrip CSS Framework`s Thin and ...
    - Adding Borders to Web Page Columns with Blue...
    - Introducing the BlueTrip CSS Framework
    - Using a Background Grid to Assist Web Page L...
    - Extending the Rule Of Thirds for Web Page La...
    - A Two-Column Web Page Layout Based on the Ru...
    - Using the Rule Of Thirds for Web Page Layout
    - Swapping Columns Using the Divine Ratio for ...
    - Using the Golden Ratio in Liquid Web Page De...
    - Fundamental Design Principles for Web Page L...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek