好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

html语言剖析表格标记

<table> <tr> <td> <th> <caption> ■ <table> <tr> <td> : 这三个标记是定义表格的最重要的标记,可以说只学这三个己足够。 <table>是一个容器标记,意思是说它用以声明这是表格而且其他表格标记只能在他的 范围内才适用,属容器标记的还有其他。 <tr>用以标示表格列(row) <td>用以标示储存格(cell) <table> 的参数设定(常用): 例如: <table width="400" border="1" cellspacing="2" cellpadding="2" align="center" valign="top" background="myweb.gif" bgcolor="#0000ff" bordercolor="#ff00ff" bordercolorlight="#00ff00" bordercolordark="#00ffff" cols="2"> width="400" 表格宽度,接受绝对值(如 80)及相对值(如 80%)。 border="1" 表格边框厚度,不同浏览器有不同的内定值,故请指明。 cellspacing="2" 表格格线厚度,请看例子三,那是加厚到 5 的格线。 cellpadding="2" 文字与格线的距离,请看例子四,那是加至 10 的 padding。 align="center" 表格的摆放位置(水平),可选值为: left, right, center,请看例子五或六,那表格 是放于中间的,为怕一些浏览器不支援,故特加上居中标记<center>,只是多 层保证而己,当然只用<center>亦可。 valign="top". 表格内字画等的摆放贴 位置(垂直),可选值为: top, middle, bottom。 background="myweb.gif" 表格 纸,与 bgcolor 不要同用。 bgcolor="#0000ff" 表格底色,与 background 不要同用,请看例子六。 bordercolor="#ff00ff" 表格边框颜色,nc 与 ie 有不同的效果,请看例子六。 bordercolorlight="#00ff00" 表格边框向光部分的颜色,请看例子二。『只适用于 ie』 bordercolordark="#00ffff" 表格边框背光部分的颜色,请看例子二,使用 bordercolorlight 或 bordercolordark 时 bordercolor 将会失效。『只适用于 ie』 cols="2" 表格栏位数目,只是让浏览器在下载表格是先画出整个表格而己。 <tr> 的参数设定(常用): 例如:<tr align="right" valign="middle" bgcolor="#0000ff" bordercolor="#ff00ff" bordercolorlight="#808080" bordercolordark="#ff0000"> align="right" 该一列内字画等的摆放贴 位置(水平),可选值为: left, center, right。 valign="middle" 该一列内字画等的摆放贴 位置(垂直),可选值为: top, middle, bottom。 bgcolor="#0000ff" 该一列底色,请看例子五。 bordercolor="#ff00ff" 该一列边框颜色,请看例子三。『只适用于 ie』 bordercolorlight="#808080" 该一列边框向光部分的颜色,请看例子三。『只适用于 ie』 bordercolordark="#ff0000" 该一列边框背光部分的颜色,请看例子三,使用 bordercolorlight 或 bordercolordark 时 bordercolor 将会失效。『只适用于 ie』 <td> 的参数设定(常用): 例如:<td width="48%" height="400" colspan="5" rowspan="4" align="right" valign="bottom" bgcolor="#ff00ff" bordercolor="#808080" bordercolorlight="#ff0000" bordercolordark="#00ff00" background="myweb.gif"> width="48%" 该一储存格宽度,接受绝对值(如 80)及相对值(如 80%)。 height="400" 该一储存格高度。 colspan="5" 该一储存格向右打通的栏数。请看例子六 rowspan="4" 该一储存格向下打通的列数。请看例子六 align="right" 该一储存格内字画等的摆放贴 位置(水平),可选值为: left, center, right。 valign="bottom" 该一储存格内字画等的摆放贴 位置(垂直),可选值为: top, middle, bottom。 bgcolor="#ff00ff" 该一储存格底色,请看例子四。 bordercolor="#808080" 该一储存格边框颜色,请看例子三。『只适用于 ie』 bordercolorlight="#ff0000" 该一储存格边框向光部分的颜色,请看例子三。『只适用于 ie』 bordercolordark="#00ff00" 该一储存格边框背光部分的颜色,请看例子三,使用 bordercolorlight 或 bordercolordark 时 bordercolor 将会失效。『只适用于 ie』 background="myweb.gif" 该一储存格 纸,与 bgcolor 任用其一。 例子一: 原始码 <table width="60%" border="1"> <tr><td>只有一个储存格(cell)的表格</td></tr> </table> 显示结果 只有一个储存格(cell)的表格 例子二: 原始码 <table width="60%" border="5" bordercolorlight="#ff00ff" bordercolordark="#ff0000"> <tr><td>第一列第一栏</td><td>第一列第二栏</td></tr> </table> 显示结果 第一列第一栏 第一列第二栏 例子三: 原始码 <table width="60%" border="1" cellspacing="5"> <tr bordercolor="#0000ff"> <td>第一列第一栏</td> <td>第一列第二栏</td> </tr> <tr bordercolorlight="#ff00ff" bordercolordark="#00ff00"> <td>第二列第一栏</td> <td>第二列第二栏</td> </tr> </table> 显示结果 第一列第一栏 第一列第二栏 第二列第一栏 第二列第二栏 例子四: 原始码 <table width="60%" border="1" cellpadding="10"> <tr> <td bgcolor="#ffcce6">第一列第一栏</td> <td bgcolor="#ffffc6">第一列第二栏</td> </tr> <tr> <td bgcolor="#ffd9ff">第二列第一栏</td> <td bgcolor="#dab4b4">第二列第二栏</td> </tr> </table> 显示结果 第一列第一栏 第一列第二栏 第二列第一栏 第二列第二栏 例子五: 原始码 <center> <table width="60%" cellspacing="0" cellpadding="2" align="center"> <tr> <td bgcolor="#ffd2e9">第一列第一栏</td> <td bgcolor="#ffdab5">第一列第二栏</td> <td bgcolor="#ffffb5">第一列第三栏</td> </tr> <tr bgcolor="#c0c0c0"> <td>第二列第一栏</td> <td>第二列第二栏</td> <td>第二列第三栏</td> </tr> </table> </center> 显示结果 第一列第一栏 第一列第二栏 第一列第三栏 第二列第一栏 第二列第二栏 第二列第三栏 例子六 原始码 <center> <table width="350" border="1" cellspacing="0" cellpadding="2" align="center" bgcolor="#ffc4e1" bordercolor="#0000ff"> <tr> <td>第一列第一栏</td> <td colspan="2">第一列 之 第二栏及第三栏</td> </tr> <tr> <td rowspan="2">第二列及第三列 之 第一栏</td> <td>第二列第二栏</td> <td>第二列第三栏</td> </tr> <tr> <td>第三列第二栏</td> <td>第三列第三栏</td> </tr> </table> </center> 显示结果 第一列第一栏 第一列 之 第二栏及第三栏 第二列及第三列 之 第一栏 第二列第二栏 第二列第三栏 第三列第二栏 第三列第三栏 ■ <th> : <th>与<td>同样是标示一个储存格,唯一不同的是<th>所标示的储存格中的文字是以粗 体出现,通常用于表格第一列以标示栏目。它的用法是取代<td>的位置便可以,其参数 设定请参考<td>。 当然若为<td>所标示的储存格中的文字加上粗体标记<b>便等如<th>的效果。 例子: 原始码 <center> <table width="350" border="1" cellspacing="0" cellpadding="2" align="center"> <tr align="center"> <th>month</th><th>% of ie visitor</th><th>% of nc visitor</th> </tr> <tr align="center"> <td>august</td><td>61%</td><td>39%</td> </tr> <tr align="center"> <td>july</td><td>54%</td><td>46%</td> </tr> <tr align="center"> <td>june</td><td>52%</td><td>48%</td> </tr> </table> </center> 显示结果 month % of ie visitor % of nc visitor august 61% 39% july 54% 46% june 52% 48% ■ <caption> : <caption> 的作用是为表格标示一个标题列,有如在表格上方加上一没格线的打通列。 当然亦可置于下方,通常用以存放该表格的标题。 <caption> 的参数设定(常用): 例如:<caption align="top" valign="top"></caption> align="top" 该表格标题列相对于表格的摆放贴 位置(水平),可选值为: left, center, right, top, middle, bottom,若 align="bottom" 的话标题列便会出现对表格的下方,不管你 的原始码中把 <caption> 放在 <table> 中的头部或尾部。 valign="top" 该表格标题列相对于表格的摆放位置(上下),可选值为: top, bottom。和 align="top" 或 align="bottom" 是一样的,虽然功能重复了,但如果你要标题列 置于下方及向右或向左贴 ,那末两个参数便可一 用了。当只 一个参数时, 请首选 align,因为 valign 是由 html 3.0 才开始的参数。 例子: 原始码 <center> <table width="350" border="1" cellspacing="0" cellpadding="2" align="center"> <caption>网页速成 八月份访客浏览器使用分析</caption> <tr align="center"> <th>month</th> <th>% of ie visitor</th> <th>% of nc visitor</th> </tr> <tr align="center"> <td>august</td> <td>61%</td> <td>39%</td> </tr> </table> </center> 显示结果 网页速成 八月份访客浏览器使用分析 month % of ie visitor % of nc visitor august 61% 39%

以上就是html语言剖析 表格标记的内容,更多相关文章请关注PHP中文网(www.gxlcms.com)!

查看更多关于html语言剖析表格标记的详细内容...

  阅读:38次