Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML table column align right

I have a table with 3 columns. I want that the third column is aligned to the right of the upper element and the other 2 columns to the left, like this:

(left column) (middle column)                                      (right column)

Is there a way to do this via CSS or something?

like image 428
Simon Lenz Avatar asked Sep 08 '10 07:09

Simon Lenz


People also ask

How do I align a column to the right in HTML?

HTML | <col> align Attribute left: It sets the text left-align. right: It sets the text right-align. center: It sets the text center-align.

How do I move a column to the right in a table in HTML?

Use width:100% on the table and the middle column. You could also set width:100% on the last column's style and td align="right" on the last column. Then you can insert more columns in the middle while the spacing still works.

How do you align columns in HTML?

Set a to zero and b to the position of the column in the table, e.g. td:nth-child(2) { text-align: right; } to right-align the second column. If the table does use a colspan attribute, the effect can be achieved by combining adequate CSS attribute selectors like [colspan=n] , though this is not trivial.


1 Answers

Use width:100% on the table and the middle column.

like image 110
Vinay B R Avatar answered Sep 19 '22 13:09

Vinay B R