What do you consider best practice for controlling...
# advancedpdf
c
What do you consider best practice for controlling column width in tables? I need to line up elements across several different tables vertically on a page (i.e get some customer info and the ship-to address lined up underneath the invoice# and date). I can't seem to get different tables to align the same way.
a
I've struggled with this, also interested in what others might have to say. I think the de facto approach is using colspan which always makes me cringe but also seems to work with the most consistency (in a single table at least), though I haven't tested other approaches all that extensively.
w
Use table-layout=“fixed” or style=“table-layout: fixed;” Using this property on the table allows you to use the width attribute on the TD tag ie <td width=“10%”>Lorem Ipsum”</td>, for my best practice I always make sure all my TD percentage are distributed and equalling to 100%,
<table layout="fixed">
<tr>
<td width="10%"></td>
<td width="20%"></td>
<td width="70%"></td>
</tr>
</table>
c
^ That is what I do as well
you can use the align style as well and get the text to be right and left aligned so it looks like a row
s
I do this exact same thing as well, it’s been the most consistent and easiest to make small changes to. Just make sure that everything adds up to 100%, and it works great.
c
Thanks, I've been using colspan like @al3xicon which works most of the time but NOT when trying to align objects across different tables
a
Next chance I get I'm definitely trying out the fixed widths