align属性定义字幕元素的对齐方式。此属性应将标题作为块元素对齐到表格的左侧,右侧,上方或下方。
具有左侧、右侧、底部、顶部对齐的<caption>元素的表格:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML <caption> align 属性使用-菜鸟教程(cainiaojc.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>测试看看 ‹/›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 属性。请使用 CSS 代替。
<caption> 的 align 属性在 HTML 4.01 中已废弃。
align 属性指定 caption 元素的对齐方式。
该属性将 caption 作为块元素向表格的左边、右边、顶部、底部进行对齐。
THTML5 不支持 <caption> align 属性。请使用 CSS 代替。
CSS 语法: <caption style="caption-side:bottom"> or <caption style="text-align:left">
在我们的 CSS 教程中,您可以找到更多有关caption-side 属性的细节。
<caption align="left|right|top|bottom">
| 值 | 描述 |
|---|---|
| left | 标题在表格的左边。 |
| right | 标题在表格的右边。 |
| top | 标题在表格的上边。 |
| bottom | 标题在表格的下边。 |