网页制作 
首页 > 网页制作 > 浏览文章

表格(TABLE)标记(TAGS)详细介绍

(编辑:jimmy 日期: 2024/9/24 浏览:3 次 )
表格的基本语法

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

带边框的表格: 


复制代码代码如下:
<table border>
<tr><th>Food</th><th>Drink</th><th>Sweet</th>
<tr><td>A</td><td>B</td><td>C</td>
</table>
Food Drink Sweet A B C


不带边框的表格:

复制代码代码如下:
<table>
<tr><th>Food</th><th>Drink</th><th>Sweet</th>
<tr><td>A</td><td>B</td><td>C</td>
</table>

Food Drink Sweet A B C

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

跨多列的表元 <th colspan=#>


复制代码代码如下:
<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>

Morning Menu Food Drink Sweet A B C

跨多行的表元 <th rowspan=#>



复制代码代码如下:
<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>
Morning Menu Food A Drink B Sweet C

 表格尺寸设置

<table border=#>

边框尺寸设置: 


复制代码代码如下:
<table border=10>
<tr><th>Food</th><th>Drink</th><th>Sweet</th>
<tr><td>A</td><td>B</td><td>C</td>
</table>
Food Drink Sweet A B C

<table border width=# height=#>

表格尺寸设置: 


复制代码代码如下:
<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>
Food Drink Sweet A B C

<table border cellspacing=#>

表元间隙设置: 


复制代码代码如下:
<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>
Food Drink Sweet A B C

<table border cellpadding=#>

表元内部空白设置: 


复制代码代码如下:
<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>
Food Drink Sweet A B C

 表格内文字的对齐/布局

<tr align=#>

<th align=#> #=left, center, right

<td align=#>

复制代码代码如下:
<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>

Food Drink Sweet A B C

<tr valign=#>

<th valign=#> #=top, middle, bottom, baseline

<td valign=#>

复制代码代码如下:
<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>

Food Drink Sweet Other A B C D

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

<table align=left>


复制代码代码如下:
<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.
Food Drink Sweet A B C

My favorites...
cookies, chocolates, and more.

<table align=right>

Food Drink Sweet A B C

My favorites...
cookies, chocolates, and more.

<table vspace=# hspace=#> #=space value 表格(TABLE)标记(TAGS)详细介绍


复制代码代码如下:
<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.
Food Drink Sweet A B C

My favorites...
cookies, chocolates, and more.

 表格的标题 表格(TABLE)标记(TAGS)详细介绍

<caption align=#> ... </caption> #=left, center, right

复制代码代码如下:
<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>

Lunch

Food Drink Sweet A B C

<caption valign=#> ... </caption> #=top, bottom

valign=top is default.


复制代码代码如下:
<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>

Food Drink Sweet A B C Lunch
上一篇:HTML相对路径(Relative Path)和绝对路径(Absolute Path)深入理解
下一篇:html 隐藏div HTML里隐藏表格TABLE或者DIV内容的css样式
一句话新闻
一文看懂荣耀MagicBook Pro 16
荣耀猎人回归!七大亮点看懂不只是轻薄本,更是游戏本的MagicBook Pro 16.
人们对于笔记本电脑有一个固有印象:要么轻薄但性能一般,要么性能强劲但笨重臃肿。然而,今年荣耀新推出的MagicBook Pro 16刷新了人们的认知——发布会上,荣耀宣布猎人游戏本正式回归,称其继承了荣耀 HUNTER 基因,并自信地为其打出“轻薄本,更是游戏本”的口号。
众所周知,寻求轻薄本的用户普遍更看重便携性、外观造型、静谧性和打字办公等用机体验,而寻求游戏本的用户则普遍更看重硬件配置、性能释放等硬核指标。把两个看似难以相干的产品融合到一起,我们不禁对它产生了强烈的好奇:作为代表荣耀猎人游戏本的跨界新物种,它究竟做了哪些平衡以兼顾不同人群的各类需求呢?
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网 SiteMap