English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Manual de referência HTML

大全 de etiquetas HTML

HTML caption align 属性

HTML caption align 属性

HTML <caption> tag

align 属性定义字幕元素的对齐方式。此属性应将标题作为块元素对齐到表格的左侧,右侧,上方或下方。

在线示例

示例
<!DOCTYPE html>
<html>
<head>-8<meta charset="utf
">-<title>HTML <caption> align 属性使用</title>3codebox.com)</title>/title>
<style>
table, th, td {
  border: 1px sólido preto;
}
</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 The <caption> align attribute is not supported. Use CSS instead.

The align attribute of <caption> in HTML 4.01 is deprecated.

The align attribute specifies the alignment of the caption element.

This attribute aligns the caption as a block element to the left, right, top, or bottom of the table.

Compatibility notes

THTML5 The <caption> align attribute is not supported. Use CSS instead.

CSS Syntax: <caption style="caption-side:bottom"> or <caption style="text-align:left">

CSS Example: Positioning Table Titles

In our CSS tutorial, you can find more aboutcaption-side Details of the attribute.

Syntax

<caption align="left|right|top|bottom">

Attribute value

ValueDescription
leftThe title is to the left of the table.
rightThe title is to the right of the table.
topThe title is above the table.
bottomThe title is below the table.

HTML <caption> tag