csshtml-tableright-align

Align right in a table cell with CSS


I have the old classic code like this,

<td align="right">

which does what it says: it right aligns the content in the cell. So if I put two buttons in this cell, they will appear at the right site of the cell.

I was refactoring this to CSS, but there doesn't seem to be anything as right align. I see text-align, but is it that the same?


Solution

  • Use

    text-align: right
    

    The text-align CSS property describes how inline content like text is aligned in its parent block element. text-align does not control the alignment of block elements itself, only their inline content.

    See

    text-align

    <td class='alnright'>text to be aligned to right</td>
    
    <style>
        .alnright { text-align: right; }
    </style>