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

所属分类: 网页制作 / HTML/Xhtml 阅读数: 332
收藏 0 赞 0 分享
表格的基本语法

<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 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.

 表格的标题

<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悬浮框架的设置使用示例(iframe加载html)

这篇文章主要介绍了html悬浮框架的设置使用示例(iframe加载html),需要的朋友可以参考下
收藏 0 赞 0 分享

html多媒体应用之网页中插入flash动画、插入音乐

这篇文章主要介绍了html中多媒体的应用之网页中插入Flash动画、插入音乐,需要的朋友可以参考下
收藏 0 赞 0 分享

html网页插入图片、加入地图索引示例讲解

这篇文章主要介绍了html网页插入图片、加入地图索引示例讲解,需要的朋友可以参考下
收藏 0 赞 0 分享

html无序列表标签和有序列表标签使用示例

这篇文章主要介绍了html无序列表标签和有序列表标签使用示例,需要的朋友可以参考下
收藏 0 赞 0 分享

html body标签详解与html常用的控制标记

这篇文章主要介绍了html body标签详解与html常用的控制标记 ,需要的朋友可以参考下
收藏 0 赞 0 分享

html文档基本结构(制作网页基础知识)

这篇文章主要介绍了html文档基本结构,也就是制作网页的基础知识,明白这些才可以做更好的网页,需要的朋友可以参考下
收藏 0 赞 0 分享

a标签怎么去下划线以及实现点击前和点击后不变色

a标签在网页中经常会用到,其默认有下划线和点击前和点击后变色,现在的需求是如何让其不带下划线,以及点击不变色,下面有个不错的教程,大家可以参考下
收藏 0 赞 0 分享

使用iframe实现提交表单不刷新页面

正常情况下,当你向服务器发送数据的时候,你的浏览器将会打开ACTION页面,并且不会重回到当前页面。但是有的时候,我们因为各种各样的要求,而不希望浏览器在提交数据的时候去刷新当前的页面或者转向到新的页面
收藏 0 赞 0 分享

在页面中调用搜索引擎以调用百度为例

在自己的页面中调用google、百度这样强大的搜索引擎想必很酷,经搜索还真有,下面是调用百度的一个代码段
收藏 0 赞 0 分享

form的默认提交方式修改方法

html的默认提交方式为get而不是post,如果想变成post必须修改,不知道的朋友可以了解下本文
收藏 0 赞 0 分享
查看更多