views:

88

answers:

5

Hello, I have a question. I am developing a card board which is 4x3. So I have tryed to do markup with XTHML Transitional. I have used containers mixed with tables. The example for first row:

<table>
 <tr>
   <div class="slot_01"></div>
   <div class="slot_02"></div>
   <div class="slot_03"></div>
   <div class="slot_04"></div>
 </tr>
 <tr>
 ...
 </tr>
</table>

Is this correctly done? Or its better to use only div/span blocks instead everywhere and make styling through css?

+1  A: 

No, You need td's in there, like this:

<table>
<tr>
<td></td>
<td></td>
</tr>
</table>

If you really need to, put your divs inside the TDs.

UpTheCreek
+1  A: 

Ideally use div/span blocks if you can, but the above code is ok, you just need to wrap each div in a td element:

<table>
 <tr>
   <td><div class="slot_01"></div></td>
   <td><div class="slot_02"></div></td>
   <td><div class="slot_03"></div></td>
   <td><div class="slot_04"></div></td>
 </tr>
 <tr>
 ...
 </tr>
</table>
danwellman
I also like your answer :)
faya
you really don't need the div in here at all. The class can go on the <td>. Also consider using <thead> and <tbody>
John Polling
i were going to use divs to have pictures inside of it which i will style out css :)
faya
Viaceslav, are you actually using this table for tabular data, or just layout? If it's just for layout then you shouldn't be using a table at all.
John Polling
I am using it just for a layout for board and cards on it :)
faya
tables should only be used for tabular data. It is semantically incorrect to use tables for anything else. The layout should be handled via CSS. XHTML / HTML is just for content, not layout
John Polling
+7  A: 

If you use a table, use table, tr, td, not div.

I think most people nowadays try to avoid tables for anything but "really tabular data" and prefer the "pure CSS" solution.

It depends a bit on your overall markup (e.g. what you want to display in the cells). In your case, I guess I would go for a tableless solution.

Ferdinand Beyer
+2  A: 

If your data is tabular in nature there's nothing wrong with using tables. Everyone else is correct - you need to use table cells instead of the divs in your sample code.

Andy Gaskell
A: 

For the lay out of the entIre page I would do it tableless. Remember: XHTML is for structure, CSS for displaying the structure.

Time Machine