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

How to center td content in HTML

青灯夜游
Release: 2021-12-23 17:10:59
Original
24850 people have browsed it

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

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

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!

Related labels:
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