You can simple check the number of rows in your controller and calculate width .
for ex:
Integer width = 100 / number_of_records;
And then use this variable in you VF/HTML. for ex.
<table>
<TH>
<TD width="{!width}">
<TD width="{!width}">
<TD width="{!width}">
</TH>
<tr>
<td>First Name</td>
<td>Last Name</td>
<td>Gender</td>
<tr/>
<table/>
I would definitely not break your column heading row and data rows into separate tables. The go-to web-dev methods for styling rarely work consistently in email HTML. You'll need to rely on in-line styles for formatting.
I generally code looping HTML output like this, because it's easier to tweak for email client adjustments:
%%[
VAR @rs, @row, @cntr, @soNumber
set @soNumber = AttributeValue("sonumber")
SET @rs = LookupRows("Sales Order Lines Import1","PBSI__SoName__c",@soNumber)
if rowcount(@rs) > 0 then
FOR @cntr = 1 to RowCount(@rs) do
var @itemNumber, @description, @qty, @um, @catalogLink, @series
SET @row = Row(@rs, @cntr)
set @itemNumber = Field(@row,"Item_Number_Name__c")
set @description = Field(@row,"pBSI__Item_SOLine_Description__c")
set @qty = FormatNumber(Field(@row,"PBSI__Quantity_Needed__c"),"N")
set @um = Field(@row,"UM__c")
set @catalogLink = Field(@row,"Datasheet__c")
set @series = Field(@row,"Series__c")
]%%
%%[ if @cntr == 1 then ]%%
<p><b>Samples in this Order:</b></p>
<table cellspacing="0" cellpadding="0" border="1">
<tr>
<td>Item Number</td>
<td>Description</td>
<td>Quantity</td>
<td>UM</td>
<td>Catalog Link</td>
</tr>
%%[ endif ]%%
<tr>
<td>%%=v(@itemNumber)=%%</td>
<td>%%=v(@description)=%%</td>
<td>%%=v(@qty)=%%</td>
<td>%%=v(@um)=%%</td>
<td><a href="%%=redirectto(@catalogLink)=%%">%%=v(@series)=%%</a></td>
</tr>
%%[ if @cntr == rowcount(@rs) then ]%%
</table>
%%[ endif ]%%
%%[
NEXT @cntr
]%%
%%[ else ]%%
<p>no rows found</p>
%%[ endif ]%%
Best Answer
I would just use the apex:dataTable component. Yes, it goes slightly against your description, but it generates pretty clean HTML as opposed to other options. http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_dataTable.htm
The other option is to utilize apex:repeat to generate your own table HTML such as: