What ways are there to try aligning the contents of a table cell? I have been requested to align a set of financial data so that the items are even on the screen and printout (that is, the decimals have to be on top of each other), but I cannot get the code to do what I want it to. Although I'm working in PHP, the segment I'm dealing with now is a simple echo of HTML table design code, with the only non-HTML data being the actual returned value.

I know there is an 'ALIGN=' command for use in table cells, but it doesn't seem to be working. I've tried every variation of 'ALIGN=RIGHT' that I can think of, and none of it seems to matter; the t able still left aligns the value anyway.

Can anyone offer any suggestions as to other ways to align the data in the cell?

Edit: Please ignore this message. This idiot (me) just discovered he's been trying to align the table from within the <FONT> tag instead of the <TD>tag. Sorry to waste anyone's time.

Recommended Answers

All 2 Replies

I'd use CSS:

<td style="text-align:right;">£993535.00</td>

Edit:

Lol. I didn't read this far:

Edit: Please ignore this message. This idiot (me) just discovered he's been trying to align the table from within the <FONT> tag instead of the <TD>tag. Sorry to waste anyone's time.

I'd still use CSS. You could do this:

<style type="text/css">
td.currency{
  text-align:right;
}
</style>

...
<tr>
<td class="currency">£993535.00</td>
</tr><tr>
<td class="currency">£92464693535.00</td>
</tr><tr>
<td class="currency">£163573535.90</td>
</tr>

in the td tag, you can specify:

<td align="char">

If you don't also specify char="#" (where # is the character you choose), guess what character it uses to align the columns. The DECIMAL POINT! Just what you need.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.