The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Right align a table cell

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #38896

    The following fiddle shows a 2×3 css table layout with 5 cells.
    Now, I want cell no. 2 to be right aligned, positioned above cell no. 5.
    I could just add an empty cell between 1 and 2, but what if the table has a variable width
    and you don’t know the number of cells in a row ? Could be 4 or 7.
    I want the no. 2 cell to always be at the utmost right position of the table.
    (position:absolute on .column doesn’t work)


    Out of interest – what is your use case for this?

    It seems you are using a table layout and then trying to force it to something a table layout was never designed to do – I’d be intrigued to see why.

    Position relative kind of works – see this CodePen – but only if you know the spacing and work it out manually so probably no good for what you want.


    thanks for your feedback.
    i’m trying to make a variable grid layout , but the top row has only 2 boxes. one left and one right.
    the remaining rows can have different numbers of boxes, and all left aligned.
    come to think of it, maybe I can use table-column-group?


    Would this do what you want?


    with the position:absolute I was already halfway, but never would’ve come up with the :first-child :last-child.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.