align屬性定義字幕元素的對(duì)齊方式。此屬性應(yīng)將標(biāo)題作為塊元素對(duì)齊到表格的左側(cè),右側(cè),上方或下方。
具有左側(cè)、右側(cè)、底部、頂部對(duì)齊的<caption>元素的表格:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML <caption> align 屬性使用-菜鳥(niǎo)教程(cainiaoplus.com)</title>
<style>
table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<p>align="left":</p>
<table>
<caption align="left">My savings</caption>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
</table>
<p>align="right":</p>
<table>
<caption align="right">My savings</caption>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
</table>
<p>align="top":</p>
<table>
<caption align="top">My savings</caption>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
</table>
<p>align="bottom":</p>
<table>
<caption align="bottom">My savings</caption>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
</table>
</body>
</html>測(cè)試看看 ?/?IEFirefoxOperaChromeSafari
所有主流瀏覽器都支持 align 屬性。
注意:
Internet Explorer 8 支持 "left", "right", "top", 和 "bottom" 值。
Internet Explorer 9+ 支持 "top", 和 "bottom" 值。
Firefox 支持 "left", "right", "top", 和 "bottom" 值。
Opera 支持 "left", "right", "top", 和 "bottom" 值。
Chrome 支持"top", 和 "bottom" 值。
Safari 支持 "top", 和 "bottom" 值。
HTML5 不支持 <caption> align 屬性。請(qǐng)使用 CSS 代替。
<caption> 的 align 屬性在 HTML 4.01 中已廢棄。
align 屬性指定 caption 元素的對(duì)齊方式。
該屬性將 caption 作為塊元素向表格的左邊、右邊、頂部、底部進(jìn)行對(duì)齊。
THTML5 不支持 <caption> align 屬性。請(qǐng)使用 CSS 代替。
CSS 語(yǔ)法: <caption style="caption-side:bottom"> or <caption style="text-align:left">
在我們的 CSS 教程中,您可以找到更多有關(guān)caption-side 屬性的細(xì)節(jié)。
<caption align="left|right|top|bottom">
| 值 | 描述 |
|---|---|
| left | 標(biāo)題在表格的左邊。 |
| right | 標(biāo)題在表格的右邊。 |
| top | 標(biāo)題在表格的上邊。 |
| bottom | 標(biāo)題在表格的下邊。 |