How to right align last two columns of a table with CSS

css, html, html-table

Solution

http://jsfiddle.net/BB9ty/

th:last-child,
td:last-child,
th:nth-last-child(2),
td:nth-last-child(2) {
    text-align: right;
}

Problem

I'd like to right align the text of last two columns of a table. ``` <table> <tr> <th>H 1</th> <th>H 2</th> <th>H 3</th> <th>H 4</th> </tr> <tr> <td rowspan='3'>1</td> <td>2</td> <td>3</td> <td>4</td> </tr> <tr> <td>2</td> <td>3</td> <td>4</td> </tr> <tr> <td>2</td> <td>3</td> <td>4</td> </tr> </table> ``` There is not the same number of columns in each row and I'm not sure how to use css:nth-child to select the last two td items in each row.

Original source

Related problems