..."; 2. Use the style attribute to add a center alignment style with the syntax "
Home >Web Front-end >HTML Tutorial >How to center td content in HTML
Setting method: 1. Use the align attribute, the syntax "
... "; 2. Use the style attribute to add a center alignment style, the syntax "< ;td style="text-align: center;">...".
The operating environment of this tutorial: Windows 7 system, HTML5 version, Dell G3 computer.
HTML sets the td content to be centered
1. Use the align attribute
align attribute specifies the unit The horizontal alignment of the content in the grid. When the attribute value is "center", set the content to be centered.
<table border="1" width="200"> <tr> <th>姓名</th> <th>年龄</th> </tr> <tr> <td align="center">Peter</td> <td>20</td> </tr> <tr> <td>Lois</td> <td>20</td> </tr> </table>
2. Use the style attribute to add a centered alignment style
<table border="1" width="200"> <tr> <th>姓名</th> <th>年龄</th> </tr> <tr> <td>Peter</td> <td>20</td> </tr> <tr> <td style="text-align: center;">Lois</td> <td>20</td> </tr> </table>
Related recommendations: "html video tutorial"
The above is the detailed content of How to center td content in HTML. For more information, please follow other related articles on the PHP Chinese website!