Better way to right align text in HTML Table

前端 未结 11 2064
无人及你
无人及你 2021-02-04 23:40

I have an HTML table with large number of rows, and I need to right align one column.

I know the following ways,

..

        
11条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-05 00:05

    The and tags that lives inside tables are designed for this purpose. If you have three columns in your table and want to align the third, add this after your opening

    tag:

     

    along with the requisite CSS:

     .your-right-align-class { text-align: right; }
    

    From the W3:

    Definition and Usage

    • The

    tag defines attribute values for one or more columns in a table.

  • The

  • tag is useful for applying styles to entire columns, instead of repeating the styles for each cell, for each row.

    提交回复
    热议问题