HTML <table> 標(biāo)簽的 align 屬性
定義和用法
align 屬性規(guī)定表格相對(duì)于周圍元素的對(duì)齊方式。
通常來(lái)說(shuō),HTML 表格的前后都會(huì)出現(xiàn)折行。通過(guò)運(yùn)用 align 屬性,可實(shí)現(xiàn)其他 HTML 元素圍繞表格的效果。
實(shí)例
一個(gè)右對(duì)齊的 HTML 表格:
<table border="1" align="right"
>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</table>
兼容性注釋
在 HTML 4.01 中,不贊成使用 body 元素的 align 屬性;在 XHTML 1.0 Strict DTD 中,不支持 body 元素的 align 屬性。
請(qǐng)使用 CSS 代替。
CSS 語(yǔ)法:<table style="float:right">
在我們的 CSS 教程中,您可以找到更多有關(guān) float 屬性的細(xì)節(jié)。
語(yǔ)法
<table align="value">
屬性值
值 | 描述 |
---|---|
left | 左對(duì)齊表格。 |
right | 右對(duì)齊表格。 |
center | 居中對(duì)齊表格。 |