找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索本站精品资源

首页 教程频道 查看内容

HTML怎么设置td内容居中

作者:模板之家 2021-12-23 19:56 109人关注

设置方法:1、利用align属性,语法“td align=center.../td”;2、利用style属性添加居中对齐样式,语法“td style=text-align: center;.../td”。

设置方法:1、利用align属性,语法“<td align="center">...</td>”;2、利用style属性添加居中对齐样式,语法“<td style="text-align: center;">...</td>”。

本教程操作环境:windows7系统、HTML5版、Dell G3电脑。

HTML设置td内容居中

1、利用align属性

align 属性规定单元格中内容的水平对齐方式。当属性值为“center”,设置居中对齐内容。

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

1.png

2、利用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>

2.png

相关推荐:《html视频教程》

以上就是HTML怎么设置td内容居中的详细内容,更多请关注模板之家(www.mb5.com.cn)其它相关文章!


路过

雷人

握手

鲜花

鸡蛋
来自: 网络收集

全部回复(0)