当前位置: 首页 > 网络学院 > 网页制作基础教程 > HTML > HTML <table>标签

HTML
HTML Head
HTML Meta
HTML URLs
HTML Scripts
HTML 属性
HTML 事件
HTML URL-encode
HTML Web服务器
HTML 摘要
HTML 实例
标签列表
标准属性
事件属性
ASCII码
特殊字符
HTTP状态消息

HTML <table>标签


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 531 ::
收藏到网摘: n/a

定义与用法

The <table> tag defines a table. Inside a <table> tag you can put table headers, table rows, table cells, and other tables.
<table>标签可用来定义表格。在<table>标签内你可以放表格的标题,表格行,表格单元以及其他的表格。


在HTML和XHTML中的区别

The "align" and "bgcolor" attributes of the table element were deprecated in HTML 4.01.
在HTML4.01中table元素的"align"和"bgcolor"属性不推荐使用

The "align" and "bgcolor" attributes of the table element are not supported in XHTML 1.0 Strict DTD.
XHTML1.0严密型DTD将不支持table元素的"align"和"bgcolor"属性


实例

代码 输出结果
<table border = "1">
<tr>
<td>Cell A</td>
<td>Cell B</td>
</tr>
</table>
Cell A Cell B


可选属性

DTD indicates in which DTD the attribute is allowed. S=Strict, T=Transitional, and F=Frameset.
下表中的DTD列指明了被支持的DTD属性。S=Strict(精确的),T=Transitional(传统的),F=Frameset(框架)

属性 描述 DTD
align left
center
right
Aligns the table. Deprecated. Use styles instead.
表格的对齐。[不推荐]请使用样式
TF
bgcolor rgb(x,x,x)
#xxxxxx
colorname
Specifies the background color of the table. Deprecated. Use styles instead.
指定表格的背景颜色[不推荐]请使用样式
TF
border pixels Specifies the border width.
指定边框的宽度

Tip: Set border="0" to display tables with no borders!
提示:设置boder="0"那么表格将不显示边框

STF
cellpadding pixels
%
Specifies the space between the cell walls and contents
指定单元格到文字间的距离
STF
cellspacing pixels
%
Specifies the space between cells
指定单元格与单元格之间的间隙
STF
frame void
above
below
hsides
lhs
rhs
vsides
box
border
Specifies how the outer borders should be displayed.
指定向外的边框应该如何显示

Note: Must be used in conjunction with the "border" attribute!
注意:必须结合"border"属性一起使用

STF
rules none
groups
rows
cols
all
Specifies the horizontal/vertical divider lines.
指定水平/垂直分隔线

Note: Must be used in conjunction with the "border" attribute!
注意:必须结合"border"属性一起使用

STF
summary text Specifies a summary of the table for speech-synthesizing/non-visual browsers
为非可视浏览器提供阅读摘要
STF
width %
pixels
Specifies the width of the table
指定表格的宽度
STF

标准属性

id, class, title, style, dir, lang, xml:lang

For a full description, go to Standard Attributes.
查看完整的属性

事件属性

onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup

For a full description, go to Event Attributes.
查看完整的属性


尝试与演示

Tables
How to create tables in an HTML document.
在HTML中建立表格

Table borders
Different table borders.
定义表格的边框

Table with no borders
A table with no borders.
一个没有边框的表格

Headings in a table
How to display table headers.
显示表格的标题

Empty cells
How to use "&nbsp;" to handle cells that have no content.
如何使用"&nbsp"来处理没有内容的单元格

Table with a caption
A table with a caption.
带有标题的表格

Table cells that span more than one row/column
How to define table cells that span more than one row or one column.
如何定义一个带有多行或多列跨度的表格

Tags inside a table
How to display elements inside other elements.
如何在另外的元素的里面显示元素

Cell padding
How to use cellpadding to create more white space between the cell content and its borders.
如何使用使用cellpadding来增加单元格到文字间的距离

Cell spacing
How to use cellspacing to increase the distance between the cells.
如何使用cellpacing来增加单元格之间的距离

Add a background color or a background image to a table
How to add a background to a table.
如何给表格加上背景

Add a background color or a background image to a table cell
How to add a background to one or more table cells.
如何为表格单元格加上一个或多个背景

Align the content in a table cell
How to use the "align" attribute to align the content of cells.
如何使用"align"属性来对齐单元格里的文字

The frame attribute
How to use the "frame" attribute to control the borders around the table.
怎样使用"frame"属性来控制表格周围的边框

评论 (0) All

登陆 | 还没注册?