How to align amounts right within centered data cells in an HTML table

I have the below HTML. How do I align amounts right within centered data cells in an HTML table .

<table>
    <tbody>
        <tr>
            <td>Name</td>
            <td>&nbsp;</td>
            <td>John Joe Joseph Doe&nbsp;</td>
        </tr>
        <tr>
            <td>&nbsp;Address</td>
            <td>&nbsp;</td>
            <td>Doestreet</td>
        </tr>
        <tr>
            <td>Amount received</td>
            <td>Amex</td>
            <td>750.00</td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>Visa</td>
            <td>250.00&nbsp;</td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>Diners</td>
            <td>300.00</td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>Total</td>
            <td><strong>1300.00</strong></td>
        </tr>
        <tr>
            <td>Amoungt paid</td>
            <td>&nbsp;</td>
            <td>1250.00</td>
        </tr>
        <tr>
            <td>Change</td>
            <td>&nbsp;</td>
            <td><strong>50.00</strong></td>
        </tr>
    </tbody>
</table>

Open in new window

Errol FarroAsked:
Who is Participating?
 
Julian HansenCommented:
How to use code tags: [ I have done this for you]
Code tags make your code easier to read. To add code tags.
1. Highlight code
2. Click the code button in the toolbar

To answer your question - you have a number of options
1. Give the cells you want to right align a class (text-right for example) then define the class
.text-right {
  text-align: right;
}

Open in new window

2. If you don't want to do that then you can target specific cells in the table - in this case the last cell
td:last-child {
  text-align: right;
}

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.