学习HTML语言(八)

社区服务
高级搜索
猴岛论坛电脑百科学习HTML语言(八)
发帖 回复
倒序阅读 最近浏览的帖子最近浏览的版块
0个回复

学习HTML语言(八)

楼层直达
happynight

ZxID:2495802

等级: 元老
潜水王(传说中的小斌)

举报 只看楼主 使用道具 楼主   发表于: 2009-03-13 0
表格(TABLE)标记(TAGS)


表格的基本语法
<table>...</table> - 定义表格
<tr> - 定义表行
<th> - 定义表头
<td> - 定义表元(表格的具体数据)

带边框的表格:
[pre]<table border><tr><th>Food</th><th>Drink</th><th>Sweet</th><tr><td>A</td><td>B</td><td>C</td>      </table>[/pre]
FoodDrinkSweet
ABC

不带边框的表格:
[pre]<table><tr><th>Food</th><th>Drink</th><th>Sweet</th><tr><td>A</td><td>B</td><td>C</td>      </table>[/pre]
FoodDrinkSweet
ABC


跨多行、多列的表元(Table Span)

跨多列的表元 <th colspan=#>
[pre]<table border><tr><th colspan=3> Morning Menu</th><tr><th>Food</th>       <th>Drink</th>  <th>Sweet</th><tr><td>A</td><td>B</td><td>C</td></table>[/pre]
Morning Menu
FoodDrinkSweet
ABC

跨多行的表元 <th rowspan=#>
[pre]<table border><tr><th rowspan=3> Morning Menu</th>        <th>Food</th> <td>A</td></tr><tr><th>Drink</th> <td>B</td></tr><tr><th>Sweet</th> <td>C</td></tr></table>[/pre]
Morning MenuFoodA
DrinkB
SweetC


表格尺寸设置

<table border=#>
边框尺寸设置:
[pre]<table border=10><tr><th>Food</th><th>Drink</th><th>Sweet</th><tr><td>A</td><td>B</td><td>C</td>      </table>[/pre]
FoodDrinkSweet
ABC

<table border width=# height=#>
表格尺寸设置:
[pre]<table border width=170 height=100><tr><th>Food</th><th>Drink</th><th>Sweet</th><tr><td>A</td><td>B</td><td>C</td>      </table>[/pre]
FoodDrinkSweet
ABC

<table border cellspacing=#>
表元间隙设置:
[pre]<table border cellspacing=10><tr><th>Food</th><th>Drink</th><th>Sweet</th><tr><td>A</td><td>B</td><td>C</td>      </table>[/pre]
FoodDrinkSweet
ABC

<table border cellpadding=#>
表元内部空白设置:
[pre]<table border cellpadding=10><tr><th>Food</th><th>Drink</th><th>Sweet</th><tr><td>A</td><td>B</td><td>C</td>      </table>[/pre]
FoodDrinkSweet
ABC


表格内文字的对齐/布局

<tr align=#>
<th align=#> #=left, center, right
<td align=#>
[pre]<table border width=160><tr>                <th>Food</th><th>Drink</th><th>Sweet</th><tr>                <td align=left>A</td>                <td align=center>B</td>                <td align=right>C</td>  </table>[/pre]
FoodDrinkSweet
ABC

<tr valign=#>
<th valign=#> #=top, middle, bottom, baseline
<td valign=#>
[pre]<table border height=100><tr>                <th>Food</th><th>Drink</th>                <th>Sweet</th><th>Other</th><tr>                <td valign=top>A</td>                <td valign=middle>B</td>                <td valign=bottom>C</td>                <td valign=baseline>D</td></table>[/pre]
FoodDrinkSweetOther
ABCD


表格在页面中的对齐/布局(Floating Table)

<table align=left>
[pre]<table align="left" border><tr><th>Food</th><th>Drink</th><th>Sweet</th><tr><td>A</td><td>B</td><td>C</td></table>My favorites...<br>cookies, chocolates, and more.[/pre]
FoodDrinkSweet
ABC
My favorites...
cookies, chocolates, and more.



<table align=right>
FoodDrinkSweet
ABC
My favorites...
cookies, chocolates, and more.


<table vspace=# hspace=#> #=space value  
[pre]<table align="left" border vspace=20 hspace=30><tr><th>Food</th><th>Drink</th><th>Sweet</th><tr><td>A</td><td>B</td><td>C</td></table>My favorites...<br>cookies, chocolates, and more.[/pre]
FoodDrinkSweet
ABC
My favorites...
cookies, chocolates, and more.



表格的标题

<caption align=#> ... </caption> #=left, center, right
[pre]<table border><caption align=center>Lunch</caption><tr><th>Food</th><th>Drink</th><th>Sweet</th><tr><td>A</td><td>B</td><td>C</td>      </table>[/pre]
Lunch
FoodDrinkSweet
ABC

<caption valign=#> ... </caption> #=top, bottom
  • valign=top is default.
[pre]<table border><caption valign=bottom>Lunch</caption><tr><th>Food</th><th>Drink</th><th>Sweet</th><tr><td>A</td><td>B</td><td>C</td>      </table>[/pre]
Lunch
FoodDrinkSweet
ABC
[ 此帖被happynight在2009-07-24 13:59重新编辑 ]
想当007么,点下图加入吧。
« 返回列表
发帖 回复