How to align center the text in html table row?

后端 未结 7 2016
不思量自难忘°
不思量自难忘° 2020-12-07 17:05

I am using an HTML

and I want to align the text of
to the center in each cell.

How do I center align the text hori

相关标签:
7条回答
  • 2020-12-07 17:57

    Here is an example with CSS and inline style attributes:

    td 
    {
        height: 50px; 
        width: 50px;
    }
    
    #cssTable td 
    {
        text-align: center; 
        vertical-align: middle;
    }
    <table border="1">
        <tr>
            <td style="text-align: center; vertical-align: middle;">Text</td>
            <td style="text-align: center; vertical-align: middle;">Text</td>
        </tr>
    </table>
    
    <table border="1" id="cssTable">
        <tr>
            <td>Text</td>
            <td>Text</td>
        </tr>
    </table>

    http://jsfiddle.net/j2h3xo9k/

    EDIT: The valign attribute is deprecated in HTML5 and should not be used.

    0 讨论(0)
提交回复
热议问题