目录搜索
文字
分享

HTML 5 <col> 标签

定义和用法

<col> 标签为表格中的一个或多个列定义属性值。您只能在表格或列组中使用该元素。

HTML 4.01 与 HTML 5 之间的差异

4.01 中的大多数属性都不再得到支持。

提示和注释

注释:col 元素是空元素。如需创建列,必须在 tr 元素内规定 td 元素。

提示:如果需要为一个或多个列规定属性值,请使用该元素。

提示:如果需要向一个列组规定相同的属性值,请使用 <colgroup> 元素。

例子:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

<table>

  <col style="color:blue" />

  <col span="2" style="color:yellow" />

  <tr>

    <td>1</td>

    <td>2</td>

    <td>3</td>

    <td>4</td>

  </tr>

  <tr>

    <td>1</td>

    <td>2</td>

    <td>3</td>

    <td>4</td>

  </tr>

</table>

属性

属性 描述 4 5
align
  • right
  • left
  • center
  • justify
  • char
定义列中的单元格内容的水平对齐方式。 4  
char character

定义一个字符,按照该字符对齐文本。

与 align="char" 使用。

4  
charoff
  • pixels
  • %
规定第一个对齐字符的偏移量。 4  
span number 定义 <col> 应当横跨的列数。 4 5
valign
  • top
  • middle
  • bottom
  • baseline
定义列中的单元格内容的垂直对齐方式。 4  
width
  • %
  • pixels
  • relative_length
定义列的宽度。 4  

标准属性

1

2

class, contenteditable, contextmenu, dir, draggable, id, irrelevant,

lang, ref, registrationmark, tabindex, template, title

如需完整的描述,请访 HTML 5 中标准属性。

事件属性

1

2

3

4

5

onabort, onbeforeunload, onblur, onchange, onclick, oncontextmenu,

ondblclick, ondrag, ondragend, ondragenter, ondragleave, ondragover,

ondragstart, ondrop, onerror, onfocus, onkeydown, onkeypress, onkeyup,

onload, onmessage, onmousedown, onmousemove, onmouseover, onmouseout,

onmouseup, onmousewheel, onresize, onscroll, onselect, onsubmit, onunload

如需完整的描述,请访 HTML 5 中事件属性。