查看完整版本: HTML简单教程 5 (表格标志)

风云际 2005-7-16 23:36

HTML简单教程 5 (表格标志)

[TABLE][TR][TD][/TD][/TR][TR][TD][TR][TD]  [TR][TD][TR][TD][ALIGN=center]教程五、表格标志[/ALIGN][/TD][/TR][TR][TD]1.<table></table>
2.<tr></tr><td></td>
3.<th></th>[/TD][/TR][TR][TD]    表格标志对于制作网页是[COLOR=#ff0000]很重要[/COLOR]的,我希望您能记住这一点,现在很多很多网页都是使用多重表格,主要是因为表格不但可以固定文本或图像的输出,而且还可以任意的进行[COLOR=#808000]背景[/COLOR]和[COLOR=#808000]前景[/COLOR]颜色的设置。但愿您也能熟练使用表格来制作您的主页。

1.<table></table>
    <table></table>标志对用来创建一个表格。它有以下属性: [TR][TD][ALIGN=center][COLOR=#008000]属性[/COLOR][/ALIGN][/TD][TD][ALIGN=center][COLOR=#008000]用途[/COLOR]

[/TD][/TR][TR][TD]<table bgcolor="">[/TD][TD]设置表格的背景色。[/TD][/TR][TR][TD]<table border="">[/TD][TD]设置[COLOR=#800000]边框的宽度[/COLOR],若不设置此属性,则边框宽度[COLOR=#008000]默认为0[/COLOR]。[/TD][/TR][TR][TD]<table bordercolor="">[/TD][TD]设置[COLOR=#800000]边框的颜色[/COLOR]。[/TD][/TR][TR][TD]<table bordercolorlight="">[/TD][TD]设置边框[COLOR=#800000]明亮[/COLOR]部分的颜色(当border的值大于等于1时才有用)。[/TD][/TR][TR][TD]<table bordercolordark="">[/TD][TD]设置边框[COLOR=#800000]昏暗[/COLOR]部分的颜色(当border的值大于等于1时才有用)。[/TD][/TR][TR][TD]<table cellspacing=""> [/TD][TD]设置表格格子之间空间的大小。[/TD][/TR][TR][TD]<table cellpadding=""> [/TD][TD]设置表格格子边框与其内部内容之间空间的大小。[/TD][/TR][TR][TD]<table width="">[/TD][TD]设置表格的宽度,单位用[COLOR=#8000ff]绝对像素值[/COLOR]或[COLOR=#8000ff]总宽度的百分比[/COLOR]。[/TD][/TR][TR][TD]    [COLOR=#0000ff]说明:[/COLOR]以上各个属性可以结合使用。有关宽度、大小的单位用[COLOR=#008040]绝对像素值[/COLOR]。而有关颜色的属性使用十六进制RGB颜色码或Html语言给定的颜色常量名(如 Silver 为银色)[/TD][/TR][/TABLE]2.<tr></tr><td></td>
    <tr></tr>标志对用来创建表格中的[COLOR=#ff0000]每一行[/COLOR]。此标志对只能放在<table></table>标志对之间使用,而在此标志对之间加入文本将是无用的,因为在<tr></tr>之间只能紧跟<td></td>标志对才是有效的语法,<td></td>标志对用来创建表格中一行中的[COLOR=#ff0000]每一个格子[/COLOR],此标志对也只有放在<tr></tr>标志对之间才是有效的,您想要输入的文本也只有放在<td></td>标志对中才有效(即才能够显示出来)。<table></table>、<tr></tr>和<td></td>标志对的关系如下所示:

[TABLE][TR][TD]最外层,创建一个表格-->[/TD][TD]<table>[/TD][/TR][TR][TD]  创建一行-->[/TD][TD][/TD][TD]<tr>[/TD][/TR][TR][TD]    创建一个格子(这里总共创建了三个格子)-->[/TD][TD][/TD][TD][/TD][TD]<td>要输出的文本只能放在此处</td>[/TD][/TR][TR][TD][/TD][TD][/TD][TD]<td>要输出的文本只能放在此处</td>[/TD][/TR][TR][TD][/TD][TD][/TD][TD]<td>要输出的文本只能放在此处</td>[/TD][/TR][TR][TD][/TD][TD][/TD][TD]</tr>[/TD][/TR][TR][TD]最外层-->[/TD][TD]</table>[/TD][/TR][/TABLE]    此外,<tr>还有[COLOR=#ff0000]align[/COLOR]和[COLOR=#ff0000]valign[/COLOR]属性。align是[COLOR=#8000ff]水平对齐方式[/COLOR],取值为[COLOR=#008000]left[/COLOR](左对齐)、[COLOR=#008000]center[/COLOR](居中)、[COLOR=#008000]right[/COLOR](右对齐);而valign是[COLOR=#8000ff]垂直对齐方式[/COLOR],取值为[COLOR=#008000]top[/COLOR](靠顶端对齐)、[COLOR=#008000]middle[/COLOR](居中间对齐)或[COLOR=#008000]bottom[/COLOR](靠底部对齐)。<td>具有[COLOR=#ff0000]width[/COLOR]、[COLOR=#ff0000]colspan[/COLOR]、[COLOR=#ff0000]rowspan[/COLOR]和[COLOR=#ff0000]nowrap[/COLOR]属性。width是格子的宽度,单位用[COLOR=#8000ff]绝对像素值[/COLOR]或[COLOR=#8000ff]总宽度的百分比[/COLOR];colspan设置一个表格格子[COLOR=#008040]跨占的列数[/COLOR](缺省值为1);rowspan设置一个表格格子[COLOR=#008040]跨占的行数[/COLOR](缺省值为1);nowrap[COLOR=#ff0000]禁止[/COLOR]表格格子内的内容[COLOR=#ff0000]自动断行[/COLOR]。

3.<th></th>
    <th></th>标志对用来设置[COLOR=#8000ff]表格头[/COLOR],通常是黑体居中文字。

    看一看下边的例子就明白以上标志对的用法了。

例6 表格标志的综合示例
[COLOR=#0000ff]<html>
<head>
<title>表格标志的综合示例</title>
</head>

<body>
<table border="1" width="80%" bgcolor="#E8E8E8" cellpadding="2" bordercolor="#0000FF"
bordercolorlight="#7D7DFF" bordercolordark="#0000A0">
  <tr>
    <th width="33%" colspan="2" valign="bottom">意大利</th>
    <th width="36%" colspan="2" valign="bottom">英格兰</th>
    <th width="36%" colspan="2" valign="bottom">西班牙</th>
  </tr>
  <tr>
    <td width="16%" align="center">AC米兰</td>
    <td width="16%" align="center">佛罗伦萨</td>
    <td width="17%" align="center">曼联</td>
    <td width="17%" align="center">纽卡斯尔</td>
    <td width="17%" align="center">巴塞罗那</td>
    <td width="17%" align="center">皇家社会</td>
  </tr>
  <tr>
    <td width="16%" align="center">尤文图斯</td>
    <td width="16%" align="center">桑普多利亚</td>
    <td width="17%" align="center">利物浦</td>
    <td width="17%" align="center">阿申纳</td>
    <td width="17%" align="center">皇家马德里</td>
    <td width="17%" align="center">……</td>
  </tr>
  <tr>
    <td width="16%" align="center">拉齐奥</td>
    <td width="16%" align="center">国际米兰</td>
    <td width="17%" align="center">切尔西</td>
    <td width="17%" align="center">米德尔斯堡</td>
    <td width="17%" align="center">马德里竞技</td>
    <td width="17%" align="center">……</td>
  </tr>
</table>
</body>
</html>[/COLOR]

    本例在浏览器中显示的结果如下:

[TABLE][TR]意大利英格兰西班牙[/TR][TR][TD]AC米兰[/TD][TD]佛罗伦萨[/TD][TD]曼联[/TD][TD]纽卡斯尔[/TD][TD]巴塞罗那[/TD][TD]皇家社会[/TD][/TR][TR][TD]尤文图斯[/TD][TD]桑普多利亚[/TD][TD]利物浦[/TD][TD]阿申纳[/TD][TD]皇家马德里[/TD][TD]……[/TD][/TR][TR][TD]拉齐奥[/TD][TD]国际米兰[/TD][TD]切尔西[/TD][TD]米德尔斯堡[/TD][TD]马德里竞技[/TD][TD]……[/TD][/TR][/TABLE][/TD][/TR] [COLOR=#0000ff] [/COLOR][/TD][/TR][/ALIGN][/TD][/TR][/TD][/TR]
页: [1]
查看完整版本: HTML简单教程 5 (表格标志)
baidu
互联网 www.ymxd.net