选择显示字体大小

html之表格标记

■ 表格标记

<table> <tr> <td>
<th>
<caption>

  欲明白本篇【html彻底剖析】之标记分类,请看 【标记一览】。
  也请先明白围堵标记与空标记的分别,请看 【html概念】。


■ <table> <tr> <td> :
▲top

  这三个标记是定义表格的最重要的标记,可以说只学这三个已足够。

  <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="#cf0000" bordercolorlight="#00ff00" bordercolordark="#00ffff" cols="2">

  • weby>widthweby>="400"
    表格宽度,接受绝对值(如 80)及相对值(如 80%)。

  • weby>border="1"
    表格边框的厚度,不同浏览器有不同的内定值,故请指明。

  • weby>cellspacing="2"
    表格格线的厚度,请看例子三,那是加厚到 5 的格线。

  • weby>cellpadding="2"
    文字与格线的距离,请看例子四,那是加至 10 的边距。

  • weby>align="center"
    表格的摆放位置(水平),可选值为: left, right, center,请看例子五或六,那表格是放于中间的,为怕一些浏览器不支持,故特意加上居中标记<center>,只是多一层保证而已,当然只用<center>也可。

  • weby>valign="top".
    表格内内容的对齐方式(垂直),可选值为: top, middle, bottom

  • weby>background="myweb.gif"
    表格的背景图片,与 bgcolor 不要同用。

  • weby>bgcolor="#0000ff"
    表格的底色,与 background 不要同用,请看例子六

  • weby>bordercolor="#cf0000"
    表格边框颜色,nc 与 ie 有不同的效果,请看例子六

  • weby>bordercolorlight="#00ff00"
    表格边框光部分的颜色,请看例子二只适用于 ie

  • weby>bordercolordark="#00ffff"
    表格边框光部分的颜色,请看例子二,使用 bordercolorlight 或 bordercolordark 时 bordercolor 将会失效。只适用于 ie

  • weby>cols="2"
    表格栏位数目,只是让浏览器在下载表格时先画出整个表格而已。

  <tr> 的参数设定(常用):

  例如:<tr align="right" valign="middle" bgcolor="#0000ff" bordercolor="#cf0000" bordercolorlight="#808080" bordercolordark="#ff0000">

  • weby>align="right"
    该一列内内容的对齐方式(水平),可选值为: left, center, right

  • weby>valign="middle"
    该一列内内容的对齐方式(垂直),可选值为: top, middle, bottom

  • weby>bgcolor="#0000ff"
    该一列底色,请看例子五

  • weby>bordercolor="#cf0000"
    该一列边框颜色,请看例子三(只适用于 ie)

  • weby>bordercolorlight="#808080"
    该一列边框光部分的颜色,请看例子三(只适用于 ie)

  • weby>bordercolordark="#ff0000"
    该一列边框光部分的颜色,请看例子三,使用 bordercolorlight 或 bordercolordark 时 bordercolor 将会失效。(只适用于 ie)

  <td> 的参数设定(常用):

  例如:<td width="48%" height="400" colspan="5" rowspan="4" align="right" valign="bottom" bgcolor="#cf0000" bordercolor="#808080" bordercolorlight="#ff0000" bordercolordark="#00ff00" background="myweb.gif">

  • weby>width="48%"
    该一储存格宽度,接受绝对值(如 80)及相对值(如 80%)。

  • weby>height="400"
    该一储存格高度。

  • weby>colspan="5"
    该一储存格向右打通的栏数。请看例子六

  • weby>rowspan="4"
    该一储存格向下打通的栏数。请看例子六

  • weby>align="right"
    该一储存格内容的对齐方式(水平),可选值为: left, center, right

  • weby>valign="bottom"
    该一储存格内容的对齐方式(垂直),可选值为: top, middle, bottom

  • weby>bgcolor="#cf0000"
    该一储存格底色,请看例子四

  • weby>bordercolor="#808080"
    该一储存格边框颜色,请看例子三(只适用于 ie)

  • weby>bordercolorlight="#ff0000"
    该一储存格边框光部分的颜色,请看例子三(只适用于 ie)

  • weby>bordercolordark="#00ff00"
    该一储存格边框光部分的颜色,请看例子三,使用 bordercolorlight 或bordercolordark 时 bordercolor 将会失效。(只适用于 ie)

  • weby>background="myweb.gif"
    该一储存格背景图片,与 bgcolor 任用其一。

例子一:

weby cellspacing=0 cellpadding=2 width="100%" border=1>
原代码<table width="60%" border="1">
<tr><td>只有一个储存格(cell)的表格</td></tr>
</table>
顯示結果

 

只有一个储存格(cell)的表格

例子二:

weby cellspacing=0 cellpadding=2 width="100%" border=1>
原代码<table width="60%" border="5" bordercolorlight="#cf0000" bordercolordark="#ff0000">
<tr><td>第一列第一栏</td><td>第一列第二栏</td></tr>
</table>
显示结果

 

第一列第一栏 第一列第二栏

例子三:

weby cellspacing=0 cellpadding=2 width="100%" border=1>
原代码<table width="60%" border="1" cellspacing="5">
     <tr bordercolor="#0000ff">
<td>第一列第一栏</td>
<td>第一列第二栏</td>
     </tr>
     <tr bordercolorlight="#cf0000" bordercolordark="#00ff00">
<td>第二列第一栏</td>
<td>第二列第二栏</td>
     </tr>
</table>
显示结果

 

第一列第一栏 第一列第二栏
第二列第一栏 第二列第二栏

例子四:

weby cellspacing=0 cellpadding=2 width="100%" border=1>
原代码<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>
显示结果

 

第一列第一栏 第一列第二栏
第二列第一栏 第二列第二栏

例子五:

weby cellspacing=0 cellpadding=2 width="100%" border=1>
原代码<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>
显示结果

第一列第一栏 第一列第二栏 第一列第三栏
第二列第一栏 第二列第二栏 第二列第三栏

例子六

weby cellspacing=0 cellpadding=2 width="100%" border=1>
原代码<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> :
▲top

  <th>与<td>同样是标记一个储存格,唯一不同的是<th>所标记的储存格中的文字是以粗体出现,通常用于表格中的标题栏目。用它取代<td>的位置便可以,其参数设定请参考<td>。

  当然你也可以在<td>所标记的文字加上粗体标记便能达到同样效果。

例子:

weby cellspacing=0 cellpadding=2 width="100%" border=1>
原代码<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
august61%39%
july54%46%
june52%48%

■ <caption> :
▲top

  <caption> 的作用是为表格标示一个标题列,如同在表格上方加一没有格线的打通列,通常用来存放表格标题。

  <caption> 的参数设定(常用):
  例如:<caption align="top" valign="top"></caption>

  • weby>align="top"
    该表格标题列相对于表格的对齐方式(水平),可选值为: left, center, right, top, middle, bottom,若 align="bottom" 的话标题列便会出现在表格的下方,不管你 的原代码是把 <caption> 放在 <table> 中的头部或尾部。

  • weby>valign="top"
    该表格标题列相对于表格的对齐方式(上下),可选值为: top, bottom。和 align="top" 或 align="bottom" 是一样的,虽然功能重复了,但如果你要标题列 置于下方及向右或向左对齐,那么两个参数便可一起用了。当只要一个参数时, 请首选 align,因为 valign 是由 html 3.0 才开始的参数。

例子:

weby cellspacing=0 cellpadding=2 width="100%" border=1>
原代码<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
august61%39%



 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons