2008年7月22日星期二

Html学习日记5

网球王子开始冲刺全国总决赛了。。。

没日没夜的看呀。。。



HTML 表格


先看一个例子:












我的博客:http://sparkzee.blogspot.com
我的QQ号:175203941
我的邮箱:点这里给我发邮件~

表格由 <table> 标签来定义。每个表格均有若干行(由 <tr> 标签定义),每行被分割为若干单元格(由 <td> 标签定义)。字母 td 指表格数据(table data),即数据单元格的内容。数据单元格可以包含文本、图片、列表、段落、表单、水平线、表格等等。

一个例子,它由两列两行组成:

<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
显示效果如下:









row 1, cell 1row 1, cell 2
row 2, cell 1row 2, cell 2

表格和边框属性

如果不定义边框属性,表格将不显示边框。有时这很有用,但是大多数时候,我们希望显示边框。

使用边框属性来显示一个带有边框的表格:

<table border="1">
<tr>
<td>Row 1, cell 1</td>
<td>Row 1, cell 2</td>
</tr>
</table>
显示效果如下:





Row 1, cell 1Row 1, cell 2

PS:这个博客貌似显示不出来框框。。。


表格的表头

表格的表头使用 <th> 标签进行定义。

<table border="1">
<tr>
<th>Heading</th>
<th>Another Heading</th>
</tr>
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>

</table>

显示效果如下:













HeadingAnother Heading
row 1, cell 1row 1, cell 2
row 2, cell 1row 2, cell 2

表格中的空单元格

在大多数浏览器中,没有内容的表格单元显示得不太好。

首先是如下代码:

<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td></td>
</tr>
</table>
显示如下:









row 1, cell 1row 1, cell 2
row 2, cell 1


注意:这个空的单元格的边框没有被显示出来。(不过 Mozilla Firefox 可以将整个边框显示出来。)为了避免这种情况,在空单元格中添加一个空格占位符,就可以将边框显示出来。

这是我们在其中加一个空格:

<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>&nbsp</td>
</tr>
</table>
显示如下:









row 1, cell 1row 1, cell 2
row 2, cell 1 

附加的表格:

垂直的表头:

源代码如下:

<table borber="1">
<tr>
<th>我的博客:</th>
<td><a href="http://sparkzee.blogspot.com">http://sparkzee.blogspot.com</a></td>
</tr>
<tr>
<th>我的QQ号:</th>
<td>175203941</td>
</tr>
<tr>
<th>我的邮箱:</th>
<td><a mailto="lohnzhang@gmail.com">点这里给我发邮件
~</a></th>
</tr>
</table>
显示效果如下:












我的博客:http://sparkzee.blogspot.com
我的QQ号:175203941
我的邮箱:点这里给我发邮件~

横跨两行的单元格:

源代码是这样的:

<table border="1">
<tr>
<th>我的博客:</th>
<td><a href="http://sparkzee.blogspot.com">http://sparkzee.blogspot.com</a></td>
</tr>
<tr>
<th rowspan="2">我的QQ\邮箱:</th>
<td>175203941</td>
</tr>
<tr>
<td><a mailto="lohnzhang@gmail.com">点这里给我发邮件~</a></th>
</tr>
</table>
显示效果如下:










我的博客: http://sparkzee.blogspot.com
我的QQ\邮箱: 175203941
点这里给我发邮件~

0 楼层:

发表评论

我的推荐