Home > Web Front-end > CSS Tutorial > How to center text in css table

How to center text in css table

WBOY
Release: 2021-11-25 16:22:04
Original
12272 people have browsed it

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;}".

How to center text in css table

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>
Copy after login

Output results:

How to center text in css table

(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!

Related labels:
css
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template