...」;2、利用style屬性加入居中對齊樣式,語法「...」。"/> ...」;2、利用style屬性加入居中對齊樣式,語法「...」。">

首頁  >  文章  >  web前端  >  HTML怎麼設定td內容置中

HTML怎麼設定td內容置中

青灯夜游
青灯夜游原創
2021-12-23 17:10:5924737瀏覽

設定方法:1.利用align屬性,語法「

...」;2、利用style屬性加入居中對齊樣式,語法「< ;td style="text-align: center;">...」。

HTML怎麼設定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>

HTML怎麼設定td內容置中

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>

HTML怎麼設定td內容置中

##相關推薦: 《

html影片教學

以上是HTML怎麼設定td內容置中的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn