In CSS, you can use the "text-align" attribute to set the center alignment of table text. This attribute is used to set the alignment of text. Setting the attribute value to "center" can achieve center alignment of text. The syntax is "table object {text-align:center;}".
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
How to center the text in the css table
In css, you can set the center alignment of the table content through the text-align attribute, text-align Property specifies the horizontal alignment of text within the element.
This attribute sets the horizontal alignment of text within block-level elements by specifying the point at which the line box is aligned. The value justify is supported by allowing user agents to adjust the spacing between letters and words in line content; different user agents may get different results.
Let’s take a look at the specific operations through examples. The examples are as follows:
<html> <body> <style> td{ text-align:center; } </style> <table border="1"> <tr> <th>Month</th> <th>Savings</th> </tr> <tr> <td>100</td> <td>100</td> </tr> </table> </body> </html>
Output results:
(Learning video sharing: css video tutorial)
The above is the detailed content of How to center text in css table. For more information, please follow other related articles on the PHP Chinese website!