tags:

views:

25

answers:

2

Hello, first of all I am not quite good at web design.

I have to dynamically create a table with a variable number of columns, determined at runtime.

Can somebody tell me if it's possible to have a html table with equal size columns that are fully stretched ?

Any hints ?

+3  A: 
<table width="400">
  <tr>
  <td width="100"></td>
  <td width="100"></td>
  <td width="100"></td>
  <td width="100"></td>
  </tr>
</table>

For variable number of columns use %

<table width="100%">
  <tr>
  <td width="(100/x)%"></td>
  </tr>
</table>

where 'x' is number of columns

Salil
+1 for second approach. But 400 what, feet? Inches? Centimeters? Pixel? Use units. :)
ANeves
+1  A: 
  1. Work out how many columns you want
  2. Work out what percentage of width each column needs: floor(100/n)
  3. Apply percentage widths to the header cells as you output them
  4. ???
  5. PROFIT!!
Oli