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

HTML 参考手册

HTML 标签大全

HTML: <col> charoff 属性

charoff属性设置将内容与char属性指定的字符对齐的字符数。只有在指定了char属性并且align属性设置为“ char”的情况下,才能使用charoff属性。

 HTML <col> tag

在线示例

在下面的 HTML 表格中,第二列的内容与字符 "." 向右两个字符的位置对齐:

!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML <col> charoff 属性使用-基础教程(oldtoolbag.com)</title>
<style>table, th, td {  border: 1px solid black;}</style>
</head>
<body>
<table style="width:100%">
  <col align="left">
  <col align="char" char="." charoff="2">
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100.00</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$10.00</td>
  </tr>
</table>
</body>
</html>
Test see ‹/›

Browser compatibility

IEFirefoxOperaChromeSafari

Note: All mainstream browsers do not support the charoff attribute.

Definition and usage

HTML5 The <col> charoff attribute is no longer supported.

The charoff attribute specifies the alignment offset of the content relative to the character specified by the char attribute.

The charoff attribute can only be used when the align attribute is set to "char" and the char attribute is already set.

Syntax

<col charoff="number">

Attribute value

ValueDescription
numberDefine the alignment method.
Positive numbers are aligned to the right of the character.
Negative numbers are aligned to the left of the character.
 HTML <col> tag