tags:

views:

150

answers:

7

I want to create table only using tag and CSS.

This is my sample table.

      <div class="divTable">
             <div class="headRow">
                <div class="divCell" align="center">Customer ID</div>
                <div  class="divCell">Customer Name</div>
                <div  class="divCell">Customer Address</div>
             </div>
            <div class="divRow">
                  <div class="divCell">001</div>
                <div class="divCell">002</div>
                <div class="divCell">003</div>
            </div>
            <div class="divRow">
                <div class="divCell">xxx</div>
                <div class="divCell">yyy</div>
                <div class="divCell">www</div>
           </div>
            <div class="divRow">
                <div class="divCell">ttt</div>
                <div class="divCell">uuu</div>
                <div class="divCell">Mkkk</div>
           </div>

      </div>
  </form>

And Style :

    .divTable
    {
        display:  table;
        width:auto;
        background-color:#eee;
        border:1px solid  #666666;
        border-spacing:5px;/*cellspacing:poor IE support for  this*/
       /* border-collapse:separate;*/
    }

    .divRow
    {
       display:table-row;
       width:auto;

    }

    .divCell
    {
        float:left;/*fix for  buggy browsers*/
        display:table-column;
        width:200px;
        background-color:#ccc;

    }



</style>

But this table not work with IE7 and below version.Please give your solution and ideas for me. Thanks.

+30  A: 

divs shouldn't be used for tabular data. That is just as wrong as using tables for layout.
Use a <table>. Its easy, semantically correct, and you'll be done in 5 minutes.

Kobi
And therefore no sane designer would come at you and be all "OMG UR A N00B COZ U USE TABLES LOL U FAIL". So don't worry, tables *do* have their place on the web :)
BoltClock
can depend on the application though. sometimes what appears tabular may be linear, although split. For instance calendars can have their benefits as divs instead tables
burnt_hand
A: 

take a look at this article

tanathos
+4  A: 

if you do the exact same markup as you would do using a table, why don't you use a table? messing araound with all this display:table-column;, display:table; and so on is just senseless.

oezi
Unfortunately, that wouldn't work either on IE7 - http://caniuse.com/#feat=css-table . I can't wait to start using these things...
Kobi
A: 

why do you want to use div to create a table?

However you could try using blueprint framework ( http://www.blueprintcss.org/ ). It's a grid framework. Should be able to get what you need.

huy
A: 

check this link please, it may be a good help

Sohail
A: 

If there is anything in <table> you don't like, maybe you could use reset file?

or

if you need this for layout of the page check out the cssplay layout examples for designing websites without tables.

Ula Karzelek
A: 

Thanks for your reply.

.col { float:left; width:100px; height:20px; border:1px solid #ccc;

}

.clearRow { clear:both; }

Header Column 1 Header Column 2 Header Column 3 Body Column 1 Body Column 2 Body Column 3 Body Column 1 Body Column 2 Body Column 3

Kumara