..."; 2. Use the style attribute to add a center alignment style with the syntax "..."."/> ..."; 2. Use the style attribute to add a center alignment style with the syntax "...".">

Home  >  Article  >  Web Front-end  >  How to center td content in HTML

How to center td content in HTML

青灯夜游
青灯夜游Original
2021-12-23 17:10:5924809browse

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

How to center td content in HTML

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>

How to center td content in HTML

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>

How to center td content in HTML

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!

Statement:
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